Unity 8
TopLevelWindowModel Class Reference

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

#include <plugins/WindowManager/TopLevelWindowModel.h>

Inherits QAbstractListModel.

Public Types

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

Signals

void countChanged ()
 
void inputMethodSurfaceChanged (unity::shell::application::MirSurfaceInterface *inputMethodSurface)
 
void focusedWindowChanged (Window *focusedWindow)
 
void applicationManagerChanged (unity::shell::application::ApplicationManagerInterface *)
 
void surfaceManagerChanged (unity::shell::application::SurfaceManagerInterface *)
 
void listChanged ()
 Emitted when the list changes. More...
 
void nextIdChanged ()
 

Public Member Functions

int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QHash< int, QByteArray > roleNames () const override
 
unity::shell::application::MirSurfaceInterface * inputMethodSurface () const
 
WindowfocusedWindow () const
 
unity::shell::application::ApplicationManagerInterface * applicationManager () const
 
void setApplicationManager (unity::shell::application::ApplicationManagerInterface *)
 
unity::shell::application::SurfaceManagerInterface * surfaceManager () const
 
void setSurfaceManager (unity::shell::application::SurfaceManagerInterface *)
 
int nextId () const
 
Q_INVOKABLE unity::shell::application::MirSurfaceInterface * surfaceAt (int index) const
 Returns the surface at the given index. More...
 
Q_INVOKABLE WindowwindowAt (int index) const
 Returns the window at the given index. More...
 
Q_INVOKABLE unity::shell::application::ApplicationInfoInterface * applicationAt (int index) const
 Returns the application at the given index.
 
Q_INVOKABLE int idAt (int index) const
 Returns the unique id of the element at the given index.
 
Q_INVOKABLE int indexForId (int id) const
 Returns the index where the row with the given id is located. More...
 
Q_INVOKABLE void raiseId (int id)
 Raises the row with the given id to the top of the window stack (index == count-1)
 

Properties

int count
 Number of top-level surfaces in this model. More...
 
unity::shell::application::MirSurfaceInterface inputMethodSurface
 The input method surface, if any. More...
 
Window focusedWindow
 The currently focused window, if any.
 
unity::shell::application::SurfaceManagerInterface surfaceManager
 
unity::shell::application::ApplicationManagerInterface applicationManager
 
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 50 of file TopLevelWindowModel.h.

Member Enumeration Documentation

§ Roles

The Roles supported by the model.

WindowRole - A Window. ApplicationRole - An ApplicationInfoInterface

Definition at line 96 of file TopLevelWindowModel.h.

96  {
97  WindowRole = Qt::UserRole,
98  ApplicationRole = Qt::UserRole + 1,
99  };

Member Function Documentation

§ indexForId()

int TopLevelWindowModel::indexForId ( int  id) const

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 510 of file TopLevelWindowModel.cpp.

511 {
512  for (int i = 0; i < m_windowModel.count(); ++i) {
513  if (m_windowModel[i].window->id() == id) {
514  return i;
515  }
516  }
517  return -1;
518 }

§ listChanged

void TopLevelWindowModel::listChanged ( )
signal

Emitted when the list changes.

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

§ surfaceAt()

unityapi::MirSurfaceInterface * TopLevelWindowModel::surfaceAt ( int  index) const

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.

Same as windowAt(index).surface()

Definition at line 529 of file TopLevelWindowModel.cpp.

530 {
531  if (index >=0 && index < m_windowModel.count()) {
532  return m_windowModel[index].window->surface();
533  } else {
534  return nullptr;
535  }
536 }

§ windowAt()

Window * TopLevelWindowModel::windowAt ( int  index) const

Returns the window at the given index.

Will always be valid

Definition at line 520 of file TopLevelWindowModel.cpp.

521 {
522  if (index >=0 && index < m_windowModel.count()) {
523  return m_windowModel[index].window;
524  } else {
525  return nullptr;
526  }
527 }

Property Documentation

§ count

int TopLevelWindowModel::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 59 of file TopLevelWindowModel.h.

§ inputMethodSurface

unityapi::MirSurfaceInterface * TopLevelWindowModel::inputMethodSurface
read

The input method surface, if any.

The surface of a onscreen keyboard (akak "virtual keyboard") would be kept here and not in the model itself.

Definition at line 66 of file TopLevelWindowModel.h.

§ nextId

int TopLevelWindowModel::nextId
read

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

Definition at line 87 of file TopLevelWindowModel.h.


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