| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-06 15:34:26 +02:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2019-08-18 10:14:26 +02:00
										 |  |  | #include <AK/LogStream.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-29 04:58:15 +01:00
										 |  |  | class GModel; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | class GModelIndex { | 
					
						
							| 
									
										
										
										
											2019-03-29 04:58:15 +01:00
										 |  |  |     friend class GModel; | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  |     GModelIndex() {} | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool is_valid() const { return m_row != -1 && m_column != -1; } | 
					
						
							|  |  |  |     int row() const { return m_row; } | 
					
						
							|  |  |  |     int column() const { return m_column; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-29 04:58:15 +01:00
										 |  |  |     void* internal_data() const { return m_internal_data; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-29 14:46:53 +01:00
										 |  |  |     GModelIndex parent() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-29 20:36:15 +01:00
										 |  |  |     bool operator==(const GModelIndex& other) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_model == other.m_model && m_row == other.m_row && m_column == other.m_column && m_internal_data == other.m_internal_data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool operator!=(const GModelIndex& other) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return !(*this == other); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-15 16:25:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-03-29 04:58:15 +01:00
										 |  |  |     GModelIndex(const GModel& model, int row, int column, void* internal_data) | 
					
						
							|  |  |  |         : m_model(&model) | 
					
						
							|  |  |  |         , m_row(row) | 
					
						
							|  |  |  |         , m_column(column) | 
					
						
							|  |  |  |         , m_internal_data(internal_data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const GModel* m_model { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  |     int m_row { -1 }; | 
					
						
							|  |  |  |     int m_column { -1 }; | 
					
						
							| 
									
										
										
										
											2019-03-29 04:58:15 +01:00
										 |  |  |     void* m_internal_data { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-02-28 01:43:50 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-08-18 10:14:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | inline const LogStream& operator<<(const LogStream& stream, const GModelIndex& value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return stream << String::format("GModelIndex(%d,%d)", value.row(), value.column()); | 
					
						
							|  |  |  | } |