Unity 8
TopLevelSurfaceList Class Reference

A model of top-level surfaces. More...

#include <plugins/WindowManager/TopLevelSurfaceList.h>

Inherits QAbstractListModel.

Public Types

enum  Roles { SurfaceRole = Qt::UserRole, ApplicationRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2 }
 The Roles supported by the model. More...
 

Public Slots

unity::shell::application::MirSurfaceInterface * surfaceAt (int index) const
 Returns the surface at the given index. More...
 
unity::shell::application::ApplicationInfoInterface * applicationAt (int index) const
 Returns the application at the given index.
 
int idAt (int index) const
 Returns the unique id of the element at the given index.
 
int indexForId (int id) const
 Returns the index where the row with the given id is located. More...
 
void raiseId (int id)
 Raises the row with the given id to index 0.
 
void doRaiseId (int id)
 

Signals

void countChanged ()
 
void listChanged ()
 Emitted when the list changes. More...
 
void nextIdChanged ()
 
void applicationsModelChanged ()
 

Public Member Functions

 TopLevelSurfaceList (QObject *parent=nullptr)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QHash< int, QByteArray > roleNames () const override
 
int nextId () const
 
QAbstractListModel * applicationsModel () const
 
void setApplicationsModel (QAbstractListModel *)
 

Properties

QAbstractListModel applicationsModel
 A list model of applications. More...
 
int count
 Number of top-level surfaces in this model. More...
 
int nextId
 

Detailed Description

A model of top-level surfaces.

It's an abstraction of top-level application windows.

When an entry first appears, it normaly doesn't have a surface yet, meaning that the application is still starting up. A shell should then display a splash screen or saved screenshot of the application until its surface comes up.

As applications can have multiple surfaces and you can also have entries without surfaces at all, the only way to unambiguously refer to an entry in this model is through its id.

Definition at line 47 of file TopLevelSurfaceList.h.

Member Enumeration Documentation

The Roles supported by the model.

SurfaceRole - A MirSurfaceInterface. It will be null if the application is still starting up ApplicationRole - An ApplicationInfoInterface IdRole - A unique identifier for this entry. Useful to unambiguosly track elements as they move around in the list

Definition at line 82 of file TopLevelSurfaceList.h.

82  {
83  SurfaceRole = Qt::UserRole,
84  ApplicationRole = Qt::UserRole + 1,
85  IdRole = Qt::UserRole + 2,
86  };

Member Function Documentation

int TopLevelSurfaceList::indexForId ( int  id) const
slot

Returns the index where the row with the given id is located.

Returns -1 if there's no row with the given id.

Definition at line 272 of file TopLevelSurfaceList.cpp.

273 {
274  for (int i = 0; i < m_surfaceList.count(); ++i) {
275  if (m_surfaceList[i].id == id) {
276  return i;
277  }
278  }
279  return -1;
280 }
void TopLevelSurfaceList::listChanged ( )
signal

Emitted when the list changes.

Emitted when model gains an element, loses an element or when elements exchange positions.

MirSurfaceInterface * TopLevelSurfaceList::surfaceAt ( int  index) const
slot

Returns the surface at the given index.

It will be a nullptr if the application is still starting up and thus hasn't yet created and drawn into a surface.

Definition at line 245 of file TopLevelSurfaceList.cpp.

246 {
247  if (index >=0 && index < m_surfaceList.count()) {
248  return m_surfaceList[index].surface;
249  } else {
250  return nullptr;
251  }
252 }

Property Documentation

QAbstractListModel * TopLevelSurfaceList::applicationsModel
readwrite

A list model of applications.

It's expected to have a role called "application" which returns a ApplicationInfoInterface

Definition at line 59 of file TopLevelSurfaceList.h.

int TopLevelSurfaceList::count
read

Number of top-level surfaces in this model.

This is the same as rowCount, added in order to keep compatibility with QML ListModels.

Definition at line 66 of file TopLevelSurfaceList.h.

int TopLevelSurfaceList::nextId
read

The id to be used on the next entry created Useful for tests

Definition at line 72 of file TopLevelSurfaceList.h.


The documentation for this class was generated from the following files: