• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • workspace API Reference
  • KDE Home
  • Contact Us
 

liblancelot

  • sources
  • kde-4.14
  • workspace
  • kdeplasma-addons
  • libs
  • lancelot
  • widgets
ActionListView.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007, 2008, 2009, 2010 Ivan Cukic <ivan.cukic(at)kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser/Library General Public License version 2,
6  * or (at your option) any later version, as published by the Free
7  * Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser/Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Lesser/Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "ActionListView.h"
21 #include "ActionListView_p.h"
22 
23 #include <QApplication>
24 #include <QGraphicsSceneMouseEvent>
25 
26 #include <KDebug>
27 
28 #include <Plasma/ItemBackground>
29 
30 #define CATEGORY_MINIMUM_SIZE 20
31 #define CATEGORY_MAXIMUM_SIZE 35
32 #define CATEGORY_PREFERRED_SIZE 27
33 
34 #define ITEM_MINIMUM_SIZE 40
35 #define ITEM_MAXIMUM_SIZE 70
36 #define ITEM_PREFERRED_SIZE 55
37 
38 namespace Lancelot {
39 
40 //> ActionListViewItem
41 
42 ActionListViewItem::ActionListViewItem(ActionListViewItemFactory * factory)
43  : ExtenderButton(), m_inSetSelected(false), m_factory(factory)
44 {
45  connect(this, SIGNAL(activated()),
46  this, SLOT(select()));
47  m_categoryTriangle.setImagePath("lancelot/category-triangle");
48 }
49 
50 ActionListViewItem::~ActionListViewItem()
51 {
52 }
53 
54 Plasma::Svg ActionListViewItem::m_categoryTriangle;
55 
56 void ActionListViewItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
57  QWidget * widget) {
58  ExtenderButton::paint(painter, option, widget);
59 
60  if (m_factory->m_categoriesActivable &&
61  m_factory->m_model->isCategory(m_factory->m_items.indexOf(this))) {
62  QSizeF diff = size() - m_categoryTriangle.size();
63  m_categoryTriangle.paint(painter,
64  diff.width() - 4,
65  diff.height() / 2
66  );
67  }
68 }
69 
70 void ActionListViewItem::select()
71 {
72  setSelected(true);
73 }
74 
75 void ActionListViewItem::deselect()
76 {
77  setSelected(false);
78  m_factory->m_selectedItem = NULL;
79 }
80 
81 void ActionListViewItem::setSelected(bool selected)
82 {
83  if (m_inSetSelected) return;
84  m_inSetSelected = true;
85 
86  // setHovered(selected);
87 
88  m_factory->setSelectedItem(this, selected);
89 
90  if (!selected) {
91  hoverLeaveEvent(NULL);
92  } else {
93  m_factory->m_view->scrollTo(geometry());
94  hoverEnterEvent(NULL);
95  }
96 
97  update();
98  m_inSetSelected = false;
99 }
100 
101 bool ActionListViewItem::isSelected() const
102 {
103  return m_factory->m_selectedItem == this;
104 }
105 
106 void ActionListViewItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
107 {
108  ExtenderButton::contextMenuEvent(event);
109  m_factory->itemContext(this);
110  event->accept();
111 }
112 
113 void ActionListViewItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
114 {
115  m_mousePos = event->pos();
116  ExtenderButton::mousePressEvent(event);
117 }
118 
119 void ActionListViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
120 {
121  ExtenderButton::mouseMoveEvent(event);
122  if (Global::self()->immutability() == Plasma::Mutable) {
123  if (isDown() && ((m_mousePos - event->pos()).toPoint().manhattanLength() > QApplication::startDragDistance())) {
124  setDown(false);
125  m_factory->itemDrag(this, event);
126  }
127  } else {
128  event->ignore();
129  }
130 }
131 
132 //<
133 
134 //> ActionListViewItemFactory
135 ActionListViewItemFactory::ActionListViewItemFactory(ActionListModel * model, ActionListView * view) //>
136  : m_model(NULL),
137  m_extenderPosition(NoExtender),
138  m_itemsGroup(NULL), m_categoriesGroup(NULL),
139  m_view(view),
140  m_categoriesActivable(false), m_itemIconSize(32, 32),
141  m_categoryIconSize(22, 22), m_selectedItem(NULL),
142  m_displayMode(ActionListView::Standard)
143 {
144  setItemsGroup(NULL);
145  setCategoriesGroup(NULL);
146  setModel(model);
147 
148  m_categoryHeight[Qt::MinimumSize] = CATEGORY_MINIMUM_SIZE;
149  m_categoryHeight[Qt::MaximumSize] = CATEGORY_MAXIMUM_SIZE;
150  m_categoryHeight[Qt::PreferredSize] = CATEGORY_PREFERRED_SIZE;
151 
152  m_itemHeight[Qt::MinimumSize] = ITEM_MINIMUM_SIZE;
153  m_itemHeight[Qt::MaximumSize] = ITEM_MAXIMUM_SIZE;
154  m_itemHeight[Qt::PreferredSize] = ITEM_PREFERRED_SIZE;
155 
156  m_selectedItemBackground = new CustomItemBackground(view->list());
157 } //<
158 
159 ActionListViewItemFactory::~ActionListViewItemFactory() //>
160 {
161  qDeleteAll(m_items);
162  m_items.clear();
163 } //<
164 
165 qreal ActionListViewItemFactory::preferredWidth() const //>
166 {
167  qreal result = 0;
168  foreach (ActionListViewItem * item, m_items) {
169  result = qMax(result, item->preferredWidth());
170  }
171  return result;
172 }
173 
174 void ActionListViewItemFactory::reload() //>
175 {
176  while (m_items.size() > m_model->size()) {
177  ActionListViewItem * item = m_items.takeLast();
178  if (m_selectedItem == item) {
179  m_selectedItem = NULL;
180  }
181  item->hide();
182  item->deleteLater();
183  }
184 
185  for (int i = 0; i < m_model->size(); i++) {
186  itemForIndex(i, true);
187  }
188 
189  emit updated();
190 } //<
191 
192 CustomListItem * ActionListViewItemFactory::itemForIndex(int index) //>
193 {
194  return itemForIndex(index, false);
195 } //<
196 
197 CustomListItem * ActionListViewItemFactory::itemForIndex(int index,
198  bool reload) //>
199 {
200  ActionListViewItem * item;
201  if (index < m_items.size() && m_items[index]) {
202  item = m_items[index];
203  } else {
204  item = new ActionListViewItem(this);
205  item->setGroup((m_model->isCategory(index))
206  ? m_categoriesGroup : m_itemsGroup);
207  reload = true;
208  while (index >= m_items.size()) {
209  m_items.append(NULL);
210  }
211  m_items[index] = item;
212  setItemExtender(index);
213  connect(item, SIGNAL(activated()),
214  this, SLOT(itemActivated()));
215  connect(item, SIGNAL(mouseHoverEnter()),
216  this, SLOT(itemHovered()));
217  }
218 
219  if (reload) {
220  switch (m_displayMode) {
221  case ActionListView::Standard:
222  item->setTitle(m_model->title(index));
223  item->setDescription(m_model->description(index));
224  break;
225 
226  case ActionListView::DescriptionFirst:
227  if (!m_model->description(index).isEmpty()) {
228  item->setTitle(m_model->description(index));
229  item->setDescription(m_model->title(index));
230  } else {
231  item->setTitle(m_model->title(index));
232  item->setDescription(QString::null);
233  }
234  break;
235 
236  case ActionListView::SingleLineNameFirst:
237  if (!m_model->description(index).isEmpty()) {
238  item->setTitle(
239  QString("%1 (%2)")
240  .arg(m_model->title(index))
241  .arg(m_model->description(index))
242  );
243  } else {
244  item->setTitle(m_model->title(index));
245  }
246 
247  item->setDescription(QString::null);
248  break;
249 
250  case ActionListView::SingleLineDescriptionFirst:
251  if (!m_model->description(index).isEmpty()) {
252  item->setTitle(
253  QString("%1 (%2)")
254  .arg(m_model->description(index))
255  .arg(m_model->title(index))
256  );
257  } else {
258  item->setTitle(m_model->title(index));
259  }
260 
261  item->setDescription(QString::null);
262  break;
263 
264  case ActionListView::OnlyName:
265  item->setTitle(m_model->title(index));
266  item->setDescription(QString::null);
267  break;
268 
269  case ActionListView::OnlyDescription:
270  if (!m_model->description(index).isEmpty()) {
271  item->setTitle(m_model->description(index));
272  } else {
273  item->setTitle(m_model->title(index));
274  }
275  item->setDescription(QString::null);
276  break;
277 
278 
279  }
280 
281 
282  item->setIcon(m_model->icon(index));
283  item->setMinimumHeight(itemHeight(index, Qt::MinimumSize));
284  item->setPreferredHeight(itemHeight(index, Qt::PreferredSize));
285  item->setMaximumHeight(itemHeight(index, Qt::MaximumSize));
286  item->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
287 
288  if (m_model->isCategory(index)) {
289  item->setGroup(m_categoriesGroup);
290  item->setIconSize(m_categoryIconSize);
291  } else {
292  item->setGroup(m_itemsGroup);
293  item->setIconSize(m_itemIconSize);
294  }
295  }
296 
297  return item;
298 } //<
299 
300 void ActionListViewItemFactory::setDisplayMode(ActionListView::ItemDisplayMode mode) //>
301 {
302  if (m_displayMode == mode) {
303  return;
304  }
305 
306  m_displayMode = mode;
307 
308 
309 
310 } //<
311 
312 ActionListView::ItemDisplayMode ActionListViewItemFactory::displayMode() const //>
313 {
314  return m_displayMode;
315 } //<
316 
317 void ActionListViewItemFactory::setItemsGroup(Group * group) //>
318 {
319  if (group == NULL) {
320  group = Global::self()->group("ActionListView-Items");
321  }
322 
323  if (group == m_itemsGroup) return;
324 
325  m_itemsGroup = group;
326 
327  int i = 0;
328  foreach(ActionListViewItem * item, m_items) {
329  if (!(m_model->isCategory(i))) {
330  item->setGroup(group);
331  }
332  i++;
333  }
334 } //<
335 
336 Group * ActionListViewItemFactory::itemsGroup() const //>
337 {
338  return m_itemsGroup;
339 } //<
340 
341 void ActionListViewItemFactory::setCategoriesGroup(Group * group) //>
342 {
343  if (group == NULL) {
344  group = Global::self()->group("ActionListView-Categories");
345  }
346 
347  if (group == m_itemsGroup) return;
348 
349  m_categoriesGroup = group;
350 
351  int i = 0;
352  foreach(ActionListViewItem * item, m_items) {
353  if (m_model->isCategory(i)) {
354  item->setGroup(group);
355  setItemExtender(i);
356  }
357  i++;
358  }
359 }
360 
361 Group * ActionListViewItemFactory::categoriesGroup() const //>
362 {
363  return m_categoriesGroup;
364 } //<
365 
366 void ActionListViewItemFactory::itemActivated() //>
367 {
368  if (!sender()) {
369  return;
370  }
371 
372  activate(m_items.indexOf(
373  (Lancelot::ActionListViewItem *)sender()));
374 } //<
375 
376 void ActionListViewItemFactory::activate(int index) //>
377 {
378  if (index < 0 || index >= m_model->size()) {
379  return;
380  }
381  m_model->activated(index);
382 
383  emit activated(index);
384 } //<
385 
386 int ActionListViewItemFactory::itemCount() const //>
387 {
388  if (m_model) {
389  return m_model->size();
390  } else {
391  return 0;
392  }
393 } //<
394 
395 void ActionListViewItemFactory::setItemHeight(int height, Qt::SizeHint which)
396 {
397  m_itemHeight[which] = height;
398  foreach (ActionListViewItem * item, m_items) {
399  int index = m_items.indexOf(item);
400  item->setMinimumHeight(itemHeight(index, Qt::MinimumSize));
401  item->setPreferredHeight(itemHeight(index, Qt::PreferredSize));
402  item->setMaximumHeight(itemHeight(index, Qt::MaximumSize));
403  }
404  emit updated();
405 }
406 
407 int ActionListViewItemFactory::itemHeight(Qt::SizeHint which) const
408 {
409  return m_itemHeight.value(which);
410 }
411 
412 void ActionListViewItemFactory::setCategoryHeight(int height, Qt::SizeHint which)
413 {
414  m_categoryHeight[which] = height;
415  foreach (ActionListViewItem * item, m_items) {
416  int index = m_items.indexOf(item);
417  item->setMinimumHeight(itemHeight(index, Qt::MinimumSize));
418  item->setPreferredHeight(itemHeight(index, Qt::PreferredSize));
419  item->setMaximumHeight(itemHeight(index, Qt::MaximumSize));
420  }
421  emit updated();
422 }
423 
424 int ActionListViewItemFactory::categoryHeight(Qt::SizeHint which) const
425 {
426  return m_categoryHeight.value(which);
427 }
428 
429 void ActionListViewItemFactory::setItemIconSize(QSize size)
430 {
431  m_itemIconSize = size;
432 
433  int i = 0;
434  foreach (ActionListViewItem * item, m_items) {
435  if (!m_model->isCategory(i)) {
436  item->setIconSize(size);
437  }
438  i++;
439  }
440  emit updated();
441 }
442 
443 QSize ActionListViewItemFactory::itemIconSize() const
444 {
445  return m_itemIconSize;
446 }
447 
448 void ActionListViewItemFactory::setCategoryIconSize(QSize size)
449 {
450  m_categoryIconSize = size;
451 
452  int i = 0;
453  foreach (ActionListViewItem * item, m_items) {
454  if (m_model->isCategory(i)) {
455  item->setIconSize(size);
456  }
457  i++;
458  }
459  emit updated();
460 }
461 
462 QSize ActionListViewItemFactory::categoryIconSize() const
463 {
464  return m_categoryIconSize;
465 }
466 
467 int ActionListViewItemFactory::itemHeight(int index, Qt::SizeHint which) const //>
468 {
469  if (m_model->isCategory(index)) {
470  return m_categoryHeight[which];
471  } else {
472  return m_itemHeight[which];
473  }
474 } //<
475 
476 void ActionListViewItemFactory::setModel(ActionListModel * model) //>
477 {
478  ActionListModel * oldmodel = m_model;
479 
480  if (m_model) {
481  disconnect(m_model, NULL, this, NULL);
482  }
483 
484  if (!model) {
485  return;
486  }
487 
488  m_model = model;
489 
490  connect(model, SIGNAL(itemInserted(int)),
491  this, SLOT(modelItemInserted(int)));
492  connect(model, SIGNAL(itemDeleted(int)),
493  this, SLOT(modelItemDeleted(int)));
494  connect(model, SIGNAL(itemAltered(int)),
495  this, SLOT(modelItemAltered(int)));
496  connect(model, SIGNAL(updated()),
497  this, SLOT(modelUpdated()));
498 
499  if (oldmodel) {
500  modelUpdated();
501  }
502 } //<
503 
504 ActionListModel * ActionListViewItemFactory::model() const //>
505 {
506  return m_model;
507 } //<
508 
509 void ActionListViewItemFactory::modelUpdated() //>
510 {
511  reload();
512 } //<
513 
514 void ActionListViewItemFactory::modelItemInserted(int index) //>
515 {
516  if (index < 0 || index > m_items.size()) {
517  // If we get an illegal notification, do
518  // a full reload
519  reload();
520  } else {
521  m_items.insert(index, NULL);
522  itemForIndex(index, true);
523  emit itemInserted(index);
524  }
525 } //<
526 
527 void ActionListViewItemFactory::modelItemDeleted(int index) //>
528 {
529  if (index < 0 || index >= m_items.size()) {
530  // If we get an illegal notification, do
531  // a full reload
532  reload();
533  } else {
534  ActionListViewItem * item = m_items.takeAt(index);
535  if (m_selectedItem == item) {
536  m_selectedItem = NULL;
537  }
538  delete item;
539  emit itemDeleted(index);
540  }
541 } //<
542 
543 void ActionListViewItemFactory::modelItemAltered(int index) //>
544 {
545  if (index < 0 || index >= m_items.size()) {
546  // If we get an illegal notification, do
547  // a full reload
548  reload();
549  } else {
550  itemForIndex(index, true);
551  emit itemAltered(index);
552  }
553 } //<
554 
555 void ActionListViewItemFactory::setExtenderPosition(int position) //>
556 {
557  if (position == TopExtender) {
558  position = LeftExtender;
559  }
560 
561  if (position == BottomExtender) {
562  position = RightExtender;
563  }
564 
565  m_extenderPosition = position;
566  updateExtenderPosition();
567 } //<
568 
569 void ActionListViewItemFactory::updateExtenderPosition() //>
570 {
571  for (int i = 0; i < m_items.count(); i++) {
572  setItemExtender(i);
573  }
574 } //<
575 
576 void ActionListViewItemFactory::setItemExtender(int index) //>
577 {
578  ActionListViewItem * item = m_items.at(index);
579  if (m_model->isCategory(index) && !m_categoriesActivable) {
580  item->setExtenderPosition(NoExtender);
581  } else {
582  item->setExtenderPosition(m_extenderPosition);
583  }
584 } //<
585 
586 int ActionListViewItemFactory::extenderPosition() const //>
587 {
588  return m_extenderPosition;
589 } //<
590 
591 void ActionListViewItemFactory::itemContext(
592  ActionListViewItem * sender, bool mouseCoordinate) //>
593 {
594  int index = m_items.indexOf(sender);
595  if (index < 0 || index >= m_model->size() ||
596  !m_model->hasContextActions(index)) {
597  return;
598  }
599 
600  Lancelot::PopupMenu menu;
601  QPoint popupPoint;
602  m_model->setContextActions(index, &menu);
603  if (!mouseCoordinate) {
604  QGraphicsScene * scene = sender->scene();
605  if (scene->views().size()) {
606  QGraphicsView * view = scene->views().at(0);
607  QPointF pos = sender->mapToScene(
608  QPointF(sender->geometry().width() * 0.7, 0));
609  popupPoint = view->mapToGlobal(
610  view->mapFromScene(pos)
611  );
612  } else {
613  mouseCoordinate = true;
614  }
615  }
616 
617  if (mouseCoordinate) {
618  popupPoint = QCursor::pos();
619  }
620 
621  m_model->contextActivate(index, menu.exec(popupPoint));
622 } //<
623 
624 void ActionListViewItemFactory::itemDrag(ActionListViewItem * sender, QGraphicsSceneMouseEvent * event) //>
625 {
626  int index = m_items.indexOf(sender);
627  if (index < 0 || index >= m_model->size()) {
628  return;
629  }
630 
631  QMimeData * data = m_model->mimeData(index);
632  if (data == NULL) {
633  return;
634  }
635 
636  QDrag * drag = new QDrag(event->widget());
637  drag->setMimeData(data);
638 
639  // Pixmap for dragger
640  QPixmap pixmap(sender->size().toSize());
641  QPainter painter(&pixmap);
642  painter.fillRect(QRect(QPoint(), pixmap.size()), QColor(100, 100, 100));
643  sender->paint(&painter, 0, 0);
644  drag->setPixmap(pixmap);
645  drag->setHotSpot(event->pos().toPoint());
646 
647  Qt::DropActions actions;
648  Qt::DropAction defaultAction;
649  m_model->setDropActions(index, actions, defaultAction);
650 
651  Qt::DropAction dropAction = drag->exec(actions, defaultAction);
652  m_model->dataDragFinished(index, dropAction);
653 
654 } //<
655 
656 void ActionListViewItemFactory::activateSelectedItem() //>
657 {
658  if (!m_selectedItem) {
659  return;
660  }
661 
662  activate(m_items.indexOf(m_selectedItem));
663 } //<
664 
665 void ActionListViewItemFactory::contextForSelectedItem() //>
666 {
667  if (!m_selectedItem) {
668  return;
669  }
670 
671  itemContext(m_selectedItem, false);
672 } //<
673 
674 void ActionListViewItemFactory::clearSelection() //>
675 {
676  if (m_selectedItem) {
677  setSelectedItem(m_selectedItem, false);
678  }
679 }
680 
681 void ActionListViewItemFactory::setSelectedItem(ActionListViewItem * item, bool selected) //>
682 {
683  if (m_selectedItem == item && !selected) {
684  if (m_selectedItem) {
685  m_selectedItem->setSelected(false);
686  }
687  m_selectedItem = NULL;
688  } else if (m_selectedItem != item && selected) {
689  if (m_selectedItem) {
690  m_selectedItem->setSelected(false);
691  }
692  m_selectedItem = item;
693  m_selectedItem->setSelected(true);
694  }
695  updateSelectedBackground(m_selectedItem);
696 } //<
697 
698 void ActionListViewItemFactory::itemHovered() //>
699 {
700  if (!sender()) {
701  return;
702  }
703 
704  Lancelot::ActionListViewItem * item =
705  static_cast < Lancelot::ActionListViewItem * > (sender());
706  updateSelectedBackground(item);
707 
708 } //<
709 
710 void ActionListViewItemFactory::updateSelectedBackground(ActionListViewItem * item) //>
711 {
712  if (!item || !item->isEnabled()) {
713  item = m_selectedItem;
714  }
715 
716  if (item) {
717 
718  QTransform transform = item->transform();
719  if (transform.isIdentity()) {
720  m_selectedItemBackground->setTarget(item->geometry());
721  } else {
722  QRectF g = item->geometry();
723  if (transform.m32() != 0) {
724  g.setHeight(g.height() * transform.m22());
725  g.moveTop(g.top() + transform.m32());
726  } else {
727  g.setHeight(g.height() * transform.m22());
728  }
729  m_selectedItemBackground->setTarget(g);
730  }
731 
732  m_selectedItemBackground->show();
733  } else {
734  m_selectedItemBackground->hide();
735  }
736 } //<
737 
738 void ActionListViewItemFactory::selectRelItem(int rel) //>
739 {
740  int index = -1;
741  if (m_selectedItem) {
742  index = m_items.indexOf(m_selectedItem);
743  }
744 
745  if (index == -1) {
746  if (rel == 1) {
747  index = 0;
748  } else {
749  index = m_items.count() - 1;
750  }
751  } else {
752  if (rel == 1) {
753  index++;
754  if (index >= m_items.count()) {
755  index = 0;
756  }
757  } else {
758  index--;
759  if (index < 0) {
760  index = m_items.count() - 1;
761  }
762  }
763  }
764 
765  if (!m_categoriesActivable) {
766  int oindex = index;
767  while (m_model->isCategory(index)) {
768  index += rel;
769  if (index == oindex) return;
770 
771  if (index < 0) {
772  index = m_items.count() - 1;
773  } else if (index >= m_items.count()) {
774  index = 0;
775  }
776  }
777  }
778 
779  if (index >= 0 && index < m_items.count()) {
780  m_items.at(index)->setSelected();
781  }
782 } //<
783 
784 //<
785 
786 //> ActionListView
787 ActionListView::Private::Private(ActionListView * listView) //>
788  : itemFactory(NULL), q(listView)
789 {
790  listView->setFlag(ScrollPane::HoverShowScrollbars);
791  listView->clearFlag(ScrollPane::ClipScrollable);
792  listView->setFocusPolicy(Qt::WheelFocus);
793 
794  Plasma::Svg * svg = new Plasma::Svg();
795  svg->setImagePath("lancelot/action-list-view-drop-indicator");
796  svg->setContainsMultipleImages(true);
797  dropIndicator = new Plasma::SvgWidget(listView->list());
798  dropIndicator->setSvg(svg);
799  dropIndicator->setElementID("drop-indicator");
800  dropIndicator->hide();
801 
802  connect(
803  Global::self(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)),
804  this, SLOT(immutabilityChanged(Plasma::ImmutabilityType)));
805 } //<
806 
807 ActionListView::Private::~Private() //>
808 {
809  delete itemFactory;
810 } //<
811 
812 void ActionListView::Private::immutabilityChanged(const Plasma::ImmutabilityType immutable) //>
813 {
814  q->setAcceptDrops(Plasma::Mutable == immutable);
815 } //<
816 
817 void ActionListView::Private::sizeHintUpdateNeeded() //>
818 {
819  q->updateGeometry();
820 } //<
821 
822 ActionListView::ActionListView(QGraphicsItem * parent) //>
823  : CustomListView(parent), d(new Private(this))
824 {
825  setModel(NULL);
826 } //<
827 
828 ActionListView::ActionListView(ActionListModel * model, QGraphicsItem * parent) //>
829  : CustomListView(parent),
830  d(new Private(this))
831 {
832  setModel(model);
833  // d->itemFactory = (ActionListViewItemFactory *) list()->itemFactory();
834  connect(
835  d->itemFactory, SIGNAL(activated(int)),
836  this, SIGNAL(activated(int)));
837 } //<
838 
839 bool ActionListView::sceneEventFilter(QGraphicsItem * object,
840  QEvent * event)
841 {
842  return CustomListView::sceneEventFilter(object, event);
843 }
844 
845 bool ActionListView::sceneEvent(QEvent * event)
846 {
847 
848  QGraphicsSceneDragDropEvent * dndEvent
849  = dynamic_cast < QGraphicsSceneDragDropEvent * > (event);
850  QRectF g;
851  switch (event->type()) {
852  case QEvent::GraphicsSceneDragEnter:
853  dndEvent->acceptProposedAction();
854  d->dropIndicator->show();
855  break;
856  case QEvent::GraphicsSceneDragLeave:
857  d->dropIndicator->hide();
858  break;
859  case QEvent::GraphicsSceneDragMove:
860  {
861  int top = dndEvent->pos().y() - list()->geometry().top();
862  int index = list()->itemAtPosition(top);
863  QGraphicsWidget * item = dynamic_cast < QGraphicsWidget * >
864  (list()->itemFactory()->itemForIndex(index));
865  if (item) {
866  g = item->geometry();
867  if (top - g.top() < g.bottom() - top) {
868  g.setTop(item->geometry().top() - 2);
869  } else {
870  g.setTop(item->geometry().bottom() - 2);
871  }
872  g.setHeight(4);
873  d->dropIndicator->setGeometry(g);
874 
875  bool allow = d->itemFactory->model()->dataDropAvailable(index, dndEvent->mimeData());
876  d->dropIndicator->setVisible(allow);
877  dndEvent->setAccepted(allow);
878  }
879  break;
880  }
881  case QEvent::GraphicsSceneDrop:
882  {
883  int top = dndEvent->pos().y() - list()->geometry().top();
884  int index = list()->itemAtPosition(top);
885  // QGraphicsWidget * item = dynamic_cast < QGraphicsWidget * >
886  // (list()->itemFactory()->itemForIndex(index));
887  // if (item) {
888  // g = item->geometry();
889  // if (top - g.top() >= g.bottom() - top) {
890  // index++;
891  // }
892  // }
893  d->itemFactory->model()->dataDropped(index, dndEvent->mimeData());
894  d->dropIndicator->hide();
895  break;
896  }
897  default:
898  // nothing
899  break;
900  }
901 
902  return CustomListView::sceneEvent(event);
903 }
904 
905 ActionListView::~ActionListView() //>
906 {
907  delete d;
908 } //<
909 
910 void ActionListView::setModel(ActionListModel * model) //>
911 {
912  if (!d->itemFactory) {
913  d->itemFactory = new ActionListViewItemFactory(
914  model, this);
915  list()->setItemFactory(d->itemFactory);
916  setAcceptDrops(Plasma::Mutable == Global::self()->immutability());
917  connect(d->itemFactory, SIGNAL(updated()),
918  d, SLOT(sizeHintUpdateNeeded()));
919  connect(d->itemFactory, SIGNAL(itemInserted(int)),
920  d, SLOT(sizeHintUpdateNeeded()));
921  connect(d->itemFactory, SIGNAL(itemDeleted(int)),
922  d, SLOT(sizeHintUpdateNeeded()));
923  connect(d->itemFactory, SIGNAL(itemAltered(int)),
924  d, SLOT(sizeHintUpdateNeeded()));
925  } else {
926  d->itemFactory->setModel(model);
927  }
928 } //<
929 
930 ActionListModel * ActionListView::model() const //>
931 {
932  if (!d->itemFactory) {
933  return NULL;
934  }
935  return d->itemFactory->model();
936 } //<
937 
938 void ActionListView::setItemHeight(int height, Qt::SizeHint which)
939 {
940  if (!d->itemFactory) {
941  return;
942  }
943  return d->itemFactory->setItemHeight(height, which);
944 }
945 
946 int ActionListView::itemHeight(Qt::SizeHint which) const
947 {
948  if (!d->itemFactory) {
949  return 0;
950  }
951  return d->itemFactory->itemHeight(which);
952 }
953 
954 void ActionListView::setCategoryHeight(int height, Qt::SizeHint which)
955 {
956  if (!d->itemFactory) {
957  return;
958  }
959  return d->itemFactory->setCategoryHeight(height, which);
960 }
961 
962 int ActionListView::categoryHeight(Qt::SizeHint which) const
963 {
964  if (!d->itemFactory) {
965  return 0;
966  }
967  return d->itemFactory->categoryHeight(which);
968 }
969 
970 void ActionListView::setItemIconSize(QSize size)
971 {
972  if (!d->itemFactory) {
973  return;
974  }
975  return d->itemFactory->setItemIconSize(size);
976 }
977 
978 QSize ActionListView::itemIconSize() const
979 {
980  if (!d->itemFactory) {
981  return QSize();
982  }
983  return d->itemFactory->itemIconSize();
984 }
985 
986 void ActionListView::setCategoryIconSize(QSize size)
987 {
988  if (!d->itemFactory) {
989  return;
990  }
991  return d->itemFactory->setCategoryIconSize(size);
992 }
993 
994 QSize ActionListView::categoryIconSize() const
995 {
996  if (!d->itemFactory) {
997  return QSize();
998  }
999  return d->itemFactory->categoryIconSize();
1000 }
1001 
1002 void ActionListView::setShowsExtendersOutside(bool value)
1003 {
1004  d->showsExtendersOutside = value;
1005  if (value) {
1006  clearFlag(ScrollPane::ClipScrollable);
1007  } else {
1008  setFlag(ScrollPane::ClipScrollable);
1009  }
1010 
1011  if (!d->itemFactory) {
1012  return;
1013  }
1014  // relayouting:
1015  setExtenderPosition(d->itemFactory->extenderPosition());
1016 }
1017 
1018 bool ActionListView::showsExtendersOutside() const
1019 {
1020  return d->showsExtendersOutside;
1021 }
1022 
1023 
1024 void ActionListView::setExtenderPosition(int position) //>
1025 {
1026  if (!d->itemFactory) {
1027  return;
1028  }
1029  d->itemFactory->setExtenderPosition(position);
1030 
1031  if (d->itemFactory->extenderPosition() == LeftExtender) {
1032  list()->setMargin(Plasma::LeftMargin,
1033  d->showsExtendersOutside ? 0 : EXTENDER_SIZE);
1034  list()->setMargin(Plasma::RightMargin, 0);
1035  setFlip(Plasma::NoFlip);
1036  } else if (d->itemFactory->extenderPosition() == RightExtender) {
1037  list()->setMargin(Plasma::LeftMargin, 0);
1038  list()->setMargin(Plasma::RightMargin,
1039  d->showsExtendersOutside ? 0 : EXTENDER_SIZE);
1040  setFlip(Plasma::HorizontalFlip);
1041  } else {
1042  list()->setMargin(Plasma::LeftMargin, 0);
1043  list()->setMargin(Plasma::RightMargin, 0);
1044  setFlip(Plasma::NoFlip);
1045  }
1046 
1047 } //<
1048 
1049 int ActionListView::extenderPosition() const //>
1050 {
1051  if (!d->itemFactory) {
1052  return NoExtender;
1053  }
1054  return d->itemFactory->extenderPosition();
1055 } //<
1056 
1057 void ActionListView::setDisplayMode(ActionListView::ItemDisplayMode mode) //>
1058 {
1059  if (!d->itemFactory) {
1060  return;
1061  }
1062 
1063  d->itemFactory->setDisplayMode(mode);
1064 } //<
1065 
1066 ActionListView::ItemDisplayMode ActionListView::displayMode() const //>
1067 {
1068  if (!d->itemFactory) {
1069  return Standard;
1070  }
1071 
1072  return d->itemFactory->displayMode();
1073 } //<
1074 
1075 void ActionListView::setItemsGroup(Group * group) //>
1076 {
1077  if (!d->itemFactory) {
1078  return;
1079  }
1080 
1081  d->itemFactory->setItemsGroup(group);
1082 } //<
1083 
1084 void ActionListView::setItemsGroupByName(const QString & group) //>
1085 {
1086  setItemsGroup(Global::self()->group(group));
1087 } //<
1088 
1089 Group * ActionListView::itemsGroup() const //>
1090 {
1091  if (!d->itemFactory) {
1092  return NULL;
1093  }
1094 
1095  return d->itemFactory->itemsGroup();
1096 } //<
1097 
1098 void ActionListView::setCategoriesGroup(Group * group) //>
1099 {
1100  if (!d->itemFactory) {
1101  return;
1102  }
1103 
1104  d->itemFactory->setCategoriesGroup(group);
1105 } //<
1106 
1107 void ActionListView::setCategoriesGroupByName(const QString & group) //>
1108 {
1109  setCategoriesGroup(Global::self()->group(group));
1110 } //<
1111 
1112 Group * ActionListView::categoriesGroup() const //>
1113 {
1114  if (!d->itemFactory) {
1115  return NULL;
1116  }
1117 
1118  return d->itemFactory->categoriesGroup();
1119 } //<
1120 
1121 void ActionListView::keyPressEvent(QKeyEvent * event) //>
1122 {
1123  if (!d->itemFactory) {
1124  return;
1125  }
1126 
1127  if (event->key() == Qt::Key_Return ||
1128  event->key() == Qt::Key_Enter) {
1129  if (event->modifiers() & Qt::AltModifier) {
1130  d->itemFactory->contextForSelectedItem();
1131  } else {
1132  d->itemFactory->activateSelectedItem();
1133  }
1134  } else if (event->key() == Qt::Key_Menu) {
1135  d->itemFactory->contextForSelectedItem();
1136  } else if (event->key() == Qt::Key_Down) {
1137  d->itemFactory->selectRelItem(+1);
1138  } else if (event->key() == Qt::Key_Up) {
1139  d->itemFactory->selectRelItem(-1);
1140  }
1141 } //<
1142 
1143 void ActionListView::clearSelection() //>
1144 {
1145  d->itemFactory->clearSelection();
1146 } //<
1147 
1148 void ActionListView::initialSelection() //>
1149 {
1150  d->itemFactory->clearSelection();
1151  d->itemFactory->selectRelItem(+1);
1152 } //<
1153 
1154 int ActionListView::selectedIndex() const //>
1155 {
1156  if (!d->itemFactory->m_selectedItem) {
1157  return -1;
1158  }
1159 
1160  return d->itemFactory->m_items.indexOf(d->itemFactory->m_selectedItem);
1161 } //>
1162 
1163 bool ActionListView::areCategoriesActivable() const //>
1164 {
1165  return d->itemFactory->m_categoriesActivable;
1166 } //<
1167 
1168 void ActionListView::setCategoriesActivable(bool value) //>
1169 {
1170  d->itemFactory->m_categoriesActivable = value;
1171  d->itemFactory->updateExtenderPosition();
1172 } //<
1173 
1174 QSizeF ActionListView::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const //>
1175 {
1176  QSizeF result;
1177  if (!group()) return result;
1178 
1179  switch (which) {
1180  case Qt::MinimumSize:
1181  result = QSizeF();
1182  break;
1183  case Qt::MaximumSize:
1184  result = MAX_WIDGET_SIZE;
1185  break;
1186  case Qt::PreferredSize:
1187  result = QSizeF(d->itemFactory->preferredWidth(), 400);
1188  result += CustomListView::sizeHint(which, constraint);
1189  // scrollbars...
1190  result.rwidth() += 50;
1191  break;
1192  default:
1193  result = QSizeF();
1194  break;
1195  }
1196  if (constraint.isValid()) {
1197  result = result.boundedTo(constraint);
1198  }
1199  return result;
1200 } //<
1201 
1202 void ActionListView::resizeEvent(QGraphicsSceneResizeEvent * event) //>
1203 {
1204  CustomListView::resizeEvent(event);
1205 
1206  if (d->itemFactory) {
1207  d->itemFactory->updateSelectedBackground();
1208  }
1209 } //<
1210 
1211 void ActionListView::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) //>
1212 {
1213  CustomListView::hoverLeaveEvent(event);
1214 
1215  if (d->itemFactory) {
1216  d->itemFactory->updateSelectedBackground();
1217  }
1218 } //<
1219 
1220 void ActionListView::show()
1221 {
1222  setVisible(true);
1223 }
1224 
1225 void ActionListView::hide()
1226 {
1227  setVisible(false);
1228 }
1229 
1230 //<
1231 
1232 } // namespace Lancelot
Lancelot::ActionListModel::hasContextActions
virtual bool hasContextActions(int index) const
Definition: ActionListModel.cpp:90
Lancelot::Widget::group
Group * group() const
Returns this widget's group.
Lancelot::ActionListViewItemFactory::activate
void activate(int index)
Definition: ActionListView.cpp:376
QGraphicsLayoutItem::preferredWidth
qreal preferredWidth() const
Lancelot::ExtenderButton::paint
L_Override void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: ExtenderButton.cpp:428
Lancelot::ActionListViewItemFactory
Definition: ActionListView_p.h:71
QTransform
ITEM_PREFERRED_SIZE
#define ITEM_PREFERRED_SIZE
Definition: ActionListView.cpp:36
QGraphicsSceneDragDropEvent::mimeData
const QMimeData * mimeData() const
Lancelot::BasicWidget::setAlignment
void setAlignment(Qt::Alignment alignment)
Sets alignment of this Lancelot::BasicWidget.
Definition: BasicWidget.cpp:496
QDrag::setHotSpot
void setHotSpot(const QPoint &hotspot)
Lancelot::NoExtender
Definition: lancelot.h:32
QEvent
Lancelot::ActionListView::ItemDisplayMode
ItemDisplayMode
Definition: ActionListView.h:48
QWidget
Lancelot::ActionListViewItemFactory::displayMode
ActionListView::ItemDisplayMode displayMode() const
Definition: ActionListView.cpp:312
QKeyEvent::modifiers
Qt::KeyboardModifiers modifiers() const
Lancelot::CustomListItemFactory::itemDeleted
void itemDeleted(int index)
This signal is emitted when an item is deleted from the model.
Lancelot::ActionListView::displayMode
ItemDisplayMode displayMode() const
Definition: ActionListView.cpp:1066
QEvent::type
Type type() const
Lancelot::ActionListView::activated
void activated(int index)
Lancelot::ActionListViewItemFactory::activateSelectedItem
void activateSelectedItem()
Definition: ActionListView.cpp:656
Lancelot::ActionListView::show
void show()
Definition: ActionListView.cpp:1220
QGraphicsScene
Lancelot::ActionListViewItemFactory::ActionListViewItem
friend class ActionListViewItem
Definition: ActionListView_p.h:165
Lancelot::ActionListView::sceneEventFilter
L_Override bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Definition: ActionListView.cpp:839
Lancelot::ExtenderButton::hoverLeaveEvent
L_Override void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: ExtenderButton.cpp:377
Lancelot::BasicWidget::setTitle
void setTitle(const QString &title)
Sets title of this Lancelot::BasicWidget.
Definition: BasicWidget.cpp:449
Lancelot::Widget::mousePressEvent
L_Override void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: Widget.cpp:98
Lancelot::CustomItemBackground::setTarget
void setTarget(const QRectF &target)
Lancelot::ActionListView::categoryIconSize
QSize categoryIconSize() const
Definition: ActionListView.cpp:994
Lancelot::ActionListView::hide
void hide()
Definition: ActionListView.cpp:1225
QGraphicsLayoutItem::setMaximumHeight
void setMaximumHeight(qreal height)
QDrag::setMimeData
void setMimeData(QMimeData *data)
Lancelot::ScrollPane::setFlip
void setFlip(Plasma::Flip flip)
Flips the layout of the scrollbars.
Definition: ScrollPane.cpp:305
Lancelot::ActionListViewItemFactory::updateExtenderPosition
void updateExtenderPosition()
Definition: ActionListView.cpp:569
QGraphicsLayoutItem::geometry
QRectF geometry() const
Lancelot::ActionListView::DescriptionFirst
Definition: ActionListView.h:50
Lancelot::ActionListModel
This class represents a list data model.
Definition: ActionListModel.h:37
Lancelot::Global::self
static Global * self()
Definition: Global.cpp:307
CATEGORY_PREFERRED_SIZE
#define CATEGORY_PREFERRED_SIZE
Definition: ActionListView.cpp:32
Lancelot::ActionListModel::isCategory
virtual bool isCategory(int index) const
Definition: ActionListModel.cpp:78
Lancelot::ActionListViewItemFactory::~ActionListViewItemFactory
~ActionListViewItemFactory()
Definition: ActionListView.cpp:159
QObject::sender
QObject * sender() const
Lancelot::ActionListView::SingleLineDescriptionFirst
Definition: ActionListView.h:52
Lancelot::ActionListViewItemFactory::setSelectedItem
void setSelectedItem(ActionListViewItem *item, bool selected=true)
Definition: ActionListView.cpp:681
QSizeF::rwidth
qreal & rwidth()
Lancelot::ActionListView::OnlyDescription
Definition: ActionListView.h:54
QDrag::setPixmap
void setPixmap(const QPixmap &pixmap)
Lancelot::ActionListViewItem::mouseMoveEvent
L_Override void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: ActionListView.cpp:119
Lancelot::ActionListView::setItemHeight
void setItemHeight(int height, Qt::SizeHint which)
Definition: ActionListView.cpp:938
Lancelot::ActionListView::showsExtendersOutside
bool showsExtendersOutside() const
Lancelot::CustomListItem
All classes that are going to be used in the CustomList must subclass this and QGraphicsWidget.
Definition: CustomListView.h:37
QGraphicsLayoutItem::setMinimumHeight
void setMinimumHeight(qreal height)
Lancelot::ActionListModel::activated
void activated(int index)
Activates the specified element.
Definition: ActionListModel.cpp:84
Lancelot::ActionListViewItemFactory::setModel
void setModel(ActionListModel *model)
Definition: ActionListView.cpp:476
Lancelot::ActionListModel::size
virtual int size() const =0
Lancelot::ActionListViewItemFactory::itemIconSize
QSize itemIconSize() const
Definition: ActionListView.cpp:443
Lancelot::CustomList::itemAtPosition
int itemAtPosition(int y) const
Definition: CustomListView.cpp:224
Lancelot::ActionListViewItemFactory::model
ActionListModel * model() const
Definition: ActionListView.cpp:504
QWidget::mapToGlobal
QPoint mapToGlobal(const QPoint &pos) const
Lancelot::ActionListView::setCategoriesActivable
void setCategoriesActivable(bool value)
Definition: ActionListView.cpp:1168
QGraphicsLayoutItem::setPreferredHeight
void setPreferredHeight(qreal height)
Lancelot::ActionListView::setShowsExtendersOutside
void setShowsExtendersOutside(bool value)
Definition: ActionListView.cpp:1002
Lancelot::ActionListView::extenderPosition
int extenderPosition() const
QRectF::top
qreal top() const
Lancelot::CustomList::setItemFactory
void setItemFactory(CustomListItemFactory *factory)
Definition: CustomListView.cpp:199
QGraphicsItem
Lancelot::ActionListView::clearSelection
void clearSelection()
Definition: ActionListView.cpp:1143
Lancelot::ActionListViewItemFactory::setItemExtender
void setItemExtender(int index)
Definition: ActionListView.cpp:576
Lancelot::CustomList::setMargin
void setMargin(Plasma::MarginEdge margin, qreal value)
Definition: CustomListView.cpp:309
Lancelot::ActionListViewItemFactory::ActionListViewItemFactory
ActionListViewItemFactory(ActionListModel *model, ActionListView *view)
Definition: ActionListView.cpp:135
QGraphicsItem::hide
void hide()
QPoint
QGraphicsSceneEvent::widget
QWidget * widget() const
Lancelot::BasicWidget::setDescription
void setDescription(const QString &description)
Sets description of this Lancelot::BasicWidget.
Definition: BasicWidget.cpp:473
Lancelot::ActionListView::model
ActionListModel * model() const
Definition: ActionListView.cpp:930
EXTENDER_SIZE
#define EXTENDER_SIZE
Definition: ExtenderButton.h:28
Lancelot::ActionListView
Definition: ActionListView.h:33
Lancelot::ActionListView::Private::Private
Private(ActionListView *listView)
Definition: ActionListView.cpp:787
Lancelot::ActionListView::keyPressEvent
L_Override void keyPressEvent(QKeyEvent *event)
Definition: ActionListView.cpp:1121
QGraphicsWidget::event
virtual bool event(QEvent *event)
Lancelot::ActionListModel::dataDropped
virtual void dataDropped(int where, const QMimeData *mimeData)
Invoked when the data is dropped into the model.
Definition: ActionListModel.cpp:59
QGraphicsItem::scene
QGraphicsScene * scene() const
Lancelot::ActionListViewItemFactory::setItemIconSize
void setItemIconSize(QSize size)
Definition: ActionListView.cpp:429
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
MAX_WIDGET_SIZE
#define MAX_WIDGET_SIZE
Definition: lancelot.h:45
Lancelot::Global::group
Group * group(const QString &name)
Definition: Global.cpp:442
QGraphicsItem::setAcceptDrops
void setAcceptDrops(bool on)
Lancelot::ActionListView::setDisplayMode
void setDisplayMode(ItemDisplayMode mode)
Definition: ActionListView.cpp:1057
QMimeData
QGraphicsItem::update
void update(const QRectF &rect)
Lancelot::ActionListView::itemsGroup
Group * itemsGroup() const
Definition: ActionListView.cpp:1089
Lancelot::ActionListView::setExtenderPosition
void setExtenderPosition(int position)
Definition: ActionListView.cpp:1024
Lancelot::ActionListView::setItemsGroup
void setItemsGroup(Group *group=NULL)
Definition: ActionListView.cpp:1075
QRectF::setHeight
void setHeight(qreal height)
QPointF
ITEM_MINIMUM_SIZE
#define ITEM_MINIMUM_SIZE
Definition: ActionListView.cpp:34
Lancelot::ActionListView::Private::~Private
~Private()
Definition: ActionListView.cpp:807
Lancelot::ActionListViewItemFactory::itemForIndex
L_Override CustomListItem * itemForIndex(int index)
Definition: ActionListView.cpp:192
Lancelot::ActionListView::sceneEvent
L_Override bool sceneEvent(QEvent *event)
Definition: ActionListView.cpp:845
Lancelot::CustomListView::list
CustomList * list() const
Definition: CustomListView.cpp:352
QGraphicsWidget::size
QSizeF size() const
Lancelot::ActionListViewItemFactory::selectRelItem
void selectRelItem(int rel)
Definition: ActionListView.cpp:738
ActionListView_p.h
Lancelot::ActionListView::categoryHeight
int categoryHeight(Qt::SizeHint which) const
Definition: ActionListView.cpp:962
QDrag::exec
Qt::DropAction exec(QFlags< Qt::DropAction > supportedActions)
Lancelot::ActionListView::setCategoryIconSize
void setCategoryIconSize(QSize size)
Definition: ActionListView.cpp:986
Lancelot::ActionListView::Private::dropIndicator
Plasma::SvgWidget * dropIndicator
Definition: ActionListView_p.h:178
QRect
Lancelot::ScrollPane::HoverShowScrollbars
Definition: ScrollPane.h:107
Lancelot::ActionListView::setItemIconSize
void setItemIconSize(QSize size)
Definition: ActionListView.cpp:970
Lancelot::CustomListItemFactory::itemInserted
void itemInserted(int index)
This signal is emitted when an item is inserted into the model.
Lancelot::CustomListItemFactory::itemAltered
void itemAltered(int index)
This signal is emitted when an item is altered.
QPointF::y
qreal y() const
QEvent::setAccepted
void setAccepted(bool accepted)
QGraphicsItem::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Lancelot::BottomExtender
Definition: lancelot.h:36
Lancelot::ActionListModel::setDropActions
virtual void setDropActions(int index, Qt::DropActions &actions, Qt::DropAction &defaultAction)
Definition: ActionListModel.cpp:71
Lancelot::BasicWidget::setIcon
void setIcon(QIcon icon)
Sets icon of this Lancelot::BasicWidget.
Definition: BasicWidget.cpp:425
Lancelot::ScrollPane::scrollTo
void scrollTo(QRectF rect)
Ensures that the specified area is visible.
Definition: ScrollPane.cpp:320
Lancelot::ActionListView::categoriesGroup
Group * categoriesGroup() const
Definition: ActionListView.cpp:1112
QGraphicsSceneMouseEvent
QTransform::m32
qreal m32() const
QGraphicsScene::views
QList< QGraphicsView * > views() const
QTransform::m22
qreal m22() const
Lancelot::ActionListViewItem::setSelected
L_Override void setSelected(bool selected=true)
Definition: ActionListView.cpp:81
QPainter
QDrag
Lancelot::Group
Represents a group of object.
Definition: Global.h:63
QString::isEmpty
bool isEmpty() const
QGraphicsWidget::sceneEvent
virtual bool sceneEvent(QEvent *event)
Lancelot::ActionListView::areCategoriesActivable
bool areCategoriesActivable() const
Definition: ActionListView.cpp:1163
Lancelot::TopExtender
Definition: lancelot.h:35
QTransform::isIdentity
bool isIdentity() const
Lancelot::ActionListModel::dataDropAvailable
virtual bool dataDropAvailable(int where, const QMimeData *mimeData)
Definition: ActionListModel.cpp:52
Lancelot::ScrollPane::clearFlag
void clearFlag(Flag flag)
Turns the specified flag off.
Definition: ScrollPane.cpp:247
Lancelot::ExtenderButton::setExtenderPosition
void setExtenderPosition(int position)
Sets the position of the extender.
Definition: ExtenderButton.cpp:383
Lancelot::ActionListModel::title
virtual QString title(int index) const =0
Lancelot::ActionListViewItemFactory::setCategoriesGroup
void setCategoriesGroup(Group *group=NULL)
Definition: ActionListView.cpp:341
QGraphicsWidget
QGraphicsView::mapFromScene
QPoint mapFromScene(const QPointF &point) const
Lancelot::ActionListModel::icon
virtual QIcon icon(int index) const
Definition: ActionListModel.cpp:40
CATEGORY_MAXIMUM_SIZE
#define CATEGORY_MAXIMUM_SIZE
Definition: ActionListView.cpp:31
QGraphicsItem::sceneEventFilter
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
QGraphicsSceneContextMenuEvent
Lancelot::ActionListView::setCategoriesGroup
void setCategoriesGroup(Group *group=NULL)
Definition: ActionListView.cpp:1098
Lancelot::ActionListView::setCategoriesGroupByName
void setCategoriesGroupByName(const QString &group)
Definition: ActionListView.cpp:1107
QString
Lancelot::ActionListView::~ActionListView
virtual ~ActionListView()
Definition: ActionListView.cpp:905
QColor
Lancelot::ActionListViewItemFactory::contextForSelectedItem
void contextForSelectedItem()
Definition: ActionListView.cpp:665
QSizeF::boundedTo
QSizeF boundedTo(const QSizeF &otherSize) const
Lancelot::CustomListView
Wrapper around the CustomList which implements the actual scrolling.
Definition: CustomListView.h:151
QGraphicsSceneResizeEvent
Lancelot::ActionListModel::dataDragFinished
virtual void dataDragFinished(int index, Qt::DropAction action)
This function is invoked when a data is dropped.
Definition: ActionListModel.cpp:65
Lancelot::ActionListViewItem::~ActionListViewItem
~ActionListViewItem()
Definition: ActionListView.cpp:50
Lancelot::BasicWidget::setIconSize
void setIconSize(QSize size)
Sets icon size of this Lancelot::BasicWidget.
Definition: BasicWidget.cpp:413
Lancelot::ActionListViewItem::contextMenuEvent
L_Override void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: ActionListView.cpp:106
QGraphicsSceneHoverEvent
Lancelot::ActionListViewItemFactory::itemDrag
void itemDrag(ActionListViewItem *sender, QGraphicsSceneMouseEvent *event)
Definition: ActionListView.cpp:624
Lancelot::ActionListViewItem::paint
L_Override void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: ActionListView.cpp:56
QPixmap
QGraphicsSceneDragDropEvent::pos
QPointF pos() const
Lancelot::ActionListViewItem::mousePressEvent
L_Override void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: ActionListView.cpp:113
QKeyEvent::key
int key() const
Lancelot::ActionListView::OnlyName
Definition: ActionListView.h:53
Lancelot::ActionListViewItemFactory::itemsGroup
Group * itemsGroup() const
Definition: ActionListView.cpp:336
QSize
Lancelot::ActionListModel::setContextActions
virtual void setContextActions(int index, Lancelot::PopupMenu *menu)
Adds actions ofr the specifies item to menu.
Definition: ActionListModel.cpp:96
Lancelot::LeftExtender
Definition: lancelot.h:34
Lancelot::ActionListViewItemFactory::categoryIconSize
QSize categoryIconSize() const
Definition: ActionListView.cpp:462
Lancelot::ActionListView::itemIconSize
QSize itemIconSize() const
Definition: ActionListView.cpp:978
Lancelot::CustomListItemFactory::updated
void updated()
This signal is emitted when the model is updated and the update is too complex to explain using itemI...
ActionListView.h
Lancelot::CustomListItemFactory::itemForIndex
virtual CustomListItem * itemForIndex(int index)=0
Lancelot::ExtenderButton::setGroup
L_Override void setGroup(Group *group=NULL)
Sets this widget's group.
Definition: ExtenderButton.cpp:340
Lancelot::PopupMenu
The popup menu class.
Definition: PopupMenu.h:37
Lancelot::CustomItemBackground
Definition: CustomItemBackground_p.h:37
QKeyEvent
Lancelot::ActionListViewItemFactory::setDisplayMode
void setDisplayMode(ActionListView::ItemDisplayMode mode)
Definition: ActionListView.cpp:300
Lancelot::ActionListViewItemFactory::setItemHeight
void setItemHeight(int height, Qt::SizeHint which)
Definition: ActionListView.cpp:395
Lancelot::ActionListView::SingleLineNameFirst
Definition: ActionListView.h:51
Lancelot::ScrollPane::ClipScrollable
Definition: ScrollPane.h:106
Lancelot::ExtenderButton::activated
void activated()
Emitted when the button is activated.
Lancelot::ActionListViewItem::ActionListViewItem
ActionListViewItem(ActionListViewItemFactory *factory)
Definition: ActionListView.cpp:42
Lancelot::ActionListView::resizeEvent
L_Override void resizeEvent(QGraphicsSceneResizeEvent *event)
Definition: ActionListView.cpp:1202
Lancelot::ActionListModel::description
virtual QString description(int index) const
Definition: ActionListModel.cpp:34
QGraphicsItem::mapToScene
QPointF mapToScene(const QPointF &point) const
Lancelot::ActionListView::Standard
Definition: ActionListView.h:49
QCursor::pos
QPoint pos()
Lancelot::ActionListView::setItemsGroupByName
void setItemsGroupByName(const QString &group)
Definition: ActionListView.cpp:1084
QSizeF
QPointF::toPoint
QPoint toPoint() const
Lancelot::ActionListView::Private
Definition: ActionListView_p.h:171
Lancelot::ActionListModel::mimeData
virtual QMimeData * mimeData(int index) const
Definition: ActionListModel.cpp:46
Qt::DropActions
typedef DropActions
Lancelot::ActionListView::Private::immutabilityChanged
void immutabilityChanged(const Plasma::ImmutabilityType immutable)
Definition: ActionListView.cpp:812
ITEM_MAXIMUM_SIZE
#define ITEM_MAXIMUM_SIZE
Definition: ActionListView.cpp:35
Lancelot::ActionListView::Private::itemFactory
ActionListViewItemFactory * itemFactory
Definition: ActionListView_p.h:177
QRectF
Lancelot::ActionListViewItemFactory::itemCount
L_Override int itemCount() const
Definition: ActionListView.cpp:386
Lancelot::ActionListViewItemFactory::setCategoryHeight
void setCategoryHeight(int height, Qt::SizeHint which)
Definition: ActionListView.cpp:412
Lancelot::CustomList::itemFactory
CustomListItemFactory * itemFactory() const
Definition: CustomListView.cpp:237
Lancelot::ActionListViewItemFactory::categoryHeight
int categoryHeight(Qt::SizeHint which) const
Definition: ActionListView.cpp:424
Lancelot::Widget::isDown
bool isDown() const
Definition: Widget.cpp:251
Lancelot::ActionListViewItemFactory::setItemsGroup
void setItemsGroup(Group *group=NULL)
Definition: ActionListView.cpp:317
Lancelot::ActionListViewItemFactory::setCategoryIconSize
void setCategoryIconSize(QSize size)
Definition: ActionListView.cpp:448
Lancelot::ActionListView::itemHeight
int itemHeight(Qt::SizeHint which) const
Definition: ActionListView.cpp:946
Lancelot::ScrollPane::resizeEvent
L_Override void resizeEvent(QGraphicsSceneResizeEvent *event)
Definition: ScrollPane.cpp:223
Lancelot::ActionListView::sizeHint
L_Override QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Definition: ActionListView.cpp:1174
QGraphicsWidget::setFocusPolicy
void setFocusPolicy(Qt::FocusPolicy policy)
Lancelot::ActionListView::ActionListView
ActionListView(QGraphicsItem *parent=0)
Definition: ActionListView.cpp:822
Lancelot::ExtenderButton::hoverEnterEvent
L_Override void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition: ExtenderButton.cpp:360
QGraphicsItem::setVisible
void setVisible(bool visible)
QStyleOptionGraphicsItem
QRectF::height
qreal height() const
Lancelot::ActionListViewItem::isSelected
L_Override bool isSelected() const
Definition: ActionListView.cpp:101
Lancelot::CustomListView::sizeHint
L_Override QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Definition: CustomListView.cpp:357
QGraphicsSceneDragDropEvent::acceptProposedAction
void acceptProposedAction()
Lancelot::ActionListViewItemFactory::activated
void activated(int index)
Lancelot::ScrollPane::hoverLeaveEvent
L_Override void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: ScrollPane.cpp:289
QGraphicsSceneDragDropEvent
Lancelot::ActionListView::hoverLeaveEvent
L_Override void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: ActionListView.cpp:1211
QGraphicsItem::contextMenuEvent
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Lancelot::ActionListViewItem
Definition: ActionListView_p.h:42
Lancelot::ExtenderButton
Button widget with special activation options beside clicking - hover and extender activation...
Definition: ExtenderButton.h:39
QGraphicsSceneMouseEvent::pos
QPointF pos() const
Lancelot::ActionListView::initialSelection
void initialSelection()
Definition: ActionListView.cpp:1148
QSizeF::height
qreal height() const
Lancelot::ActionListViewItemFactory::categoriesGroup
Group * categoriesGroup() const
Definition: ActionListView.cpp:361
QRectF::moveTop
void moveTop(qreal y)
Lancelot::PopupMenu::exec
QAction * exec(const QPoint &p, QAction *action=0)
Definition: PopupMenu.cpp:127
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Lancelot::ActionListView::setModel
void setModel(ActionListModel *model)
Definition: ActionListView.cpp:910
QObject::parent
QObject * parent() const
Lancelot::ActionListView::Private::showsExtendersOutside
bool showsExtendersOutside
Definition: ActionListView_p.h:179
Lancelot::ActionListView::selectedIndex
int selectedIndex() const
CATEGORY_MINIMUM_SIZE
#define CATEGORY_MINIMUM_SIZE
Definition: ActionListView.cpp:30
Lancelot::ActionListView::Private::sizeHintUpdateNeeded
void sizeHintUpdateNeeded()
Definition: ActionListView.cpp:817
QGraphicsWidget::geometry
geometry
QGraphicsView
Lancelot::ActionListViewItemFactory::clearSelection
void clearSelection()
Definition: ActionListView.cpp:674
Lancelot::ActionListView::setCategoryHeight
void setCategoryHeight(int height, Qt::SizeHint which)
Definition: ActionListView.cpp:954
Lancelot::ActionListViewItemFactory::itemContext
void itemContext(ActionListViewItem *sender, bool mouseCoordinate=true)
Definition: ActionListView.cpp:591
Lancelot::Widget::setDown
void setDown(bool value)
Sets whether the widget is down (pressed).
Definition: Widget.cpp:92
Lancelot::ActionListViewItemFactory::itemHeight
L_Override int itemHeight(int index, Qt::SizeHint which) const
Definition: ActionListView.cpp:467
QSizeF::width
qreal width() const
Lancelot::ActionListViewItemFactory::setExtenderPosition
void setExtenderPosition(int position)
Definition: ActionListView.cpp:555
Lancelot::ScrollPane::setFlag
void setFlag(Flag flag)
Turns the specified flag on.
Definition: ScrollPane.cpp:241
QApplication::startDragDistance
int startDragDistance()
Lancelot::ActionListModel::contextActivate
virtual void contextActivate(int index, QAction *context)
Method for handling context menu actions.
Definition: ActionListModel.cpp:102
Lancelot::RightExtender
Definition: lancelot.h:33
QMap::value
const T value(const Key &key) const
Lancelot::ActionListViewItemFactory::extenderPosition
int extenderPosition() const
Definition: ActionListView.cpp:586
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:43:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

liblancelot

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

workspace API Reference

Skip menu "workspace API Reference"
  • kdeplasma-addons
  •       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