| 
									
										
										
										
											2016-12-10 22:39:53 +00:00
										 |  |  | #include "models/folder.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | #include "database.h"
 | 
					
						
							|  |  |  | #include "uuid.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-10 22:39:53 +00:00
										 |  |  | using namespace jop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 15:04:27 +01:00
										 |  |  | Folder::Folder() : Item() {} | 
					
						
							| 
									
										
										
										
											2016-12-10 22:39:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 15:04:27 +01:00
										 |  |  | Table Folder::table() const { | 
					
						
							|  |  |  | 	return jop::FoldersTable; | 
					
						
							| 
									
										
										
										
											2016-12-10 22:39:53 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 15:04:27 +01:00
										 |  |  | bool Folder::primaryKeyIsUuid() const { | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-02 13:17:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 15:04:27 +01:00
										 |  |  | bool Folder::trackChanges() const { | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | int Folder::count() { | 
					
						
							| 
									
										
										
										
											2017-01-02 13:17:15 +01:00
										 |  |  | 	return BaseModel::count(jop::FoldersTable); | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QVector<Folder> Folder::all(const QString &orderBy) { | 
					
						
							| 
									
										
										
										
											2017-01-02 16:28:03 +01:00
										 |  |  | 	QSqlQuery q("SELECT " + BaseModel::tableFieldNames(jop::FoldersTable).join(",") + " FROM " + BaseModel::tableName(jop::FoldersTable) + " ORDER BY " + orderBy); | 
					
						
							| 
									
										
										
										
											2017-01-02 15:17:03 +01:00
										 |  |  | 	jop::db().execQuery(q); | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	QVector<Folder> output; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (q.next()) { | 
					
						
							|  |  |  | 		Folder folder; | 
					
						
							| 
									
										
										
										
											2017-01-02 13:17:15 +01:00
										 |  |  | 		folder.loadSqlQuery(q); | 
					
						
							| 
									
										
										
										
											2017-01-01 23:20:06 +01:00
										 |  |  | 		output.push_back(folder); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return output; | 
					
						
							|  |  |  | } |