CFx SDK Documentation  2022 SP0
FxUIModelIndex.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2021 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "../../sdk/UI/FxUIObject.h"
20 
22 
24 {
25  friend class CFxUIAbstractItemModel;
26 public:
27 
28  enum UIDataRole {
29  DisplayRole = 0,
30  DecorationRole = 1,
31  EditRole = 2,
32  ToolTipRole = 3,
33  TextColorRole = 9,
34 
35  // Reserved
36  UserRole = 0x0100
37  };
38 
39  enum UIItemFlags {
40  NoItemFlags = 0,
41  ItemIsSelectable = 1,
42  ItemIsEditable = 2,
43  ItemIsEnabled = 32,
44  };
45 
46 
48  Horizontal = 0x1,
49  Vertical = 0x2
50  };
51 
52  inline CFxUIModelIndex() : r( -1 ), c( -1 ), i( 0 ), m( nullptr ) {};
53  // compiler-generated copy/move ctors/assignment operators are fine!
54  inline int row() const { return r; };
55  inline int column() const { return c; };
56  inline quintptr internalId() const { return i; };
57  inline void *internalPointer() const { return reinterpret_cast< void* >( i ); };
58  inline CFxUIModelIndex parent() const;
59  inline CFxUIVariant data( int role = UIDataRole::DisplayRole ) const;
60  inline UIItemFlags flags() const;
61  inline const CFxUIAbstractItemModel *model() const { return m; };
62  inline bool isValid() const { return ( r >= 0 ) && ( c >= 0 ) && ( m != nullptr ); };
63  inline bool operator==( const CFxUIModelIndex &other ) const
64  {
65  return ( other.r == r ) && ( other.i == i ) && ( other.c == c ) && ( other.m == m );
66  };
67  inline bool operator!=( const CFxUIModelIndex &other ) const
68  {
69  return !( *this == other );
70  };
71  inline bool operator<( const CFxUIModelIndex &other ) const
72  {
73  return r < other.r
74  || ( r == other.r && ( c < other.c
75  || ( c == other.c && ( i < other.i
76  || ( i == other.i && std::less<const CFxUIAbstractItemModel *>()( m, other.m ) ) ) ) ) );
77  };
78 private:
79  inline CFxUIModelIndex( int arow, int acolumn, void *ptr, const CFxUIAbstractItemModel *amodel )
80  : r( arow ), c( acolumn ), i( reinterpret_cast< quintptr >( ptr ) ), m( amodel )
81  {
82  };
83  inline CFxUIModelIndex( int arow, int acolumn, quintptr id, const CFxUIAbstractItemModel *amodel )
84  : r( arow ), c( acolumn ), i( id ), m( amodel )
85  {
86  };
87 
88  int r, c;
89  qintptr i;
90  const CFxUIAbstractItemModel *m;
91 };
#define COMMONUI_API
QVariant CFxUIVariant
Definition: FxUIObject.h:52
virtual CFxUIModelIndex::UIItemFlags flags(const CFxUIModelIndex &index) const
void * internalPointer() const
bool isValid() const
bool operator!=(const CFxUIModelIndex &other) const
int row() const
int column() const
bool operator==(const CFxUIModelIndex &other) const
quintptr internalId() const
bool operator<(const CFxUIModelIndex &other) const
const CFxUIAbstractItemModel * model() const
CFxUIObject * parent()
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110