digikam
abstractalbummodelpriv.h
Go to the documentation of this file.00001 /* ============================================================ 00002 * 00003 * This file is a part of digiKam project 00004 * http://www.digikam.org 00005 * 00006 * Date : 2009-03-23 00007 * Description : Qt Model for Albums - abstract base classes private header 00008 * 00009 * Copyright (C) 2008-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 00010 * 00011 * This program is free software; you can redistribute it 00012 * and/or modify it under the terms of the GNU General 00013 * Public License as published by the Free Software Foundation; 00014 * either version 2, or (at your option) 00015 * any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * ============================================================ */ 00023 00024 #ifndef ABSTRACTALBUMMODELPRIVATE_H 00025 #define ABSTRACTALBUMMODELPRIVATE_H 00026 00027 namespace Digikam 00028 { 00029 00030 class AlbumModelPriv 00031 { 00032 public: 00033 00034 AlbumModelPriv() 00035 { 00036 rootAlbum = 0; 00037 type = Album::PHYSICAL; 00038 rootBehavior = AbstractAlbumModel::IncludeRootAlbum; 00039 addingAlbum = 0; 00040 removingAlbum = 0; 00041 itemDrag = true; 00042 itemDrop = true; 00043 dragDropHandler 00044 = 0; 00045 } 00046 00047 Album *rootAlbum; 00048 Album::Type type; 00049 AbstractAlbumModel::RootAlbumBehavior 00050 rootBehavior; 00051 bool itemDrag; 00052 bool itemDrop; 00053 AlbumModelDragDropHandler 00054 *dragDropHandler; 00055 00056 Album *addingAlbum; 00057 Album *removingAlbum; 00058 00059 Album *findNthChild(Album *parent, int n) 00060 { 00061 // return the n-th of the children of parent, or 0 00062 Album *a = parent->firstChild(); 00063 if (!a) 00064 return 0; 00065 for (int i=0; i<n; ++i) 00066 { 00067 a = a->next(); 00068 if (!a) 00069 return 0; 00070 } 00071 return a; 00072 } 00073 00074 int findIndexAsChild(Album *child) 00075 { 00076 // return index of child in the list of children of its parent 00077 Album *parent = child->parent(); 00078 if (!parent) 00079 return 0; 00080 Album *a = parent->firstChild(); 00081 int i = 0; 00082 while (a != child) 00083 { 00084 a = a->next(); 00085 if (!a) 00086 return -1; 00087 ++i; 00088 } 00089 return i; 00090 } 00091 00092 int numberOfChildren(Album *parent) 00093 { 00094 Album *a = parent->firstChild(); 00095 int count = 0; 00096 while (a) 00097 { 00098 ++count; 00099 a = a->next(); 00100 } 00101 return count; 00102 } 00103 }; 00104 00105 } // namespace Digikam 00106 00107 #endif // ABSTRACTALBUMMODELPRIVATE_H
KDE 4.4 API Reference