00001 /* 00002 * Copyright (C) 2006, iRex Technologies B.V. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2, or (at your option) 00007 * any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #include "DisplayList.h" 00020 #include "PDFView.h" 00021 #include "controller.h" 00022 00023 CDisplayList::CDisplayList(void) 00024 { 00025 } 00026 00027 CDisplayList::~CDisplayList(void) 00028 { 00029 clear(); 00030 } 00031 00032 void CDisplayList::clear() 00033 { 00034 while (displayList.getLength() > 0) 00035 { 00036 delete (TodoItem *)displayList.del(0); 00037 } 00038 } 00039 00040 void CDisplayList::add(TodoItem * item) 00041 { 00042 displayList.append(item); 00043 } 00044 00045 GBool CDisplayList::remove(const int pn) 00046 { 00047 TodoItem * pItem = NULL; 00048 for(int i = 0; i < displayList.getLength(); ++i) 00049 { 00050 pItem = (TodoItem *)displayList.get(i); 00051 if (pItem && pn == pItem->pageNumber) 00052 { 00053 delete pItem; 00054 displayList.del(i); 00055 return gTrue; 00056 } 00057 } 00058 return gFalse; 00059 } 00060 00061 GBool CDisplayList::isEmpty() 00062 { 00063 return ( 0 == displayList.getLength()); 00064 } 00065 00066 void CDisplayList::issueItems(CPDFView *view) 00067 { 00068 TodoItem * pItem = NULL; 00069 for(int i = 0; i < displayList.getLength(); ++i) 00070 { 00071 pItem = (TodoItem *)displayList.get(i); 00072 if (pItem && 0 != pItem->timeStamp) 00073 { 00074 // only add items that are not in rendering 00075 view->issueItem(pItem->pageNumber); 00076 } 00077 } 00078 view->ctrl->thread.signal(); 00079 } 00080 00081 void CDisplayList::renderItems(CPDFView *view) 00082 { 00083 TodoItem * pItem = NULL; 00084 for(int i = 1; i < displayList.getLength(); ++i) 00085 { 00086 pItem = (TodoItem *)displayList.get(i); 00087 if (pItem) 00088 { 00089 view->issueItem(pItem->pageNumber); 00090 } 00091 } 00092 pItem = (TodoItem *)displayList.get(0); 00093 TodoItem * item = new TodoItem(*pItem); 00094 view->ctrl->thread.renderPageNow(item); 00095 }