Ejemplo n.º 1
0
bool Timetable::loadTimetable(std::string timetablefile) {
    this->timetablefile = timetablefile;

    deleteEntries();

    char buff[1024];

    //store file modified time
    struct stat fileinfo;
    int rc = stat(timetablefile.c_str(), &fileinfo);

    if(rc !=0) return false;

    last_modified_time = fileinfo.st_mtime;

    std::ifstream in(timetablefile.c_str());
    if(!in.is_open()) return false;

    while(in.getline(buff, 1024)) {
        std::string line = std::string(buff);
        std::vector<std::string> matches;

        if(timetable_entry_regex.match(line, &matches)) {
            addEntry(matches[1], matches[2], matches[0]);
        }
    }

    in.close();

    return true;
}
Ejemplo n.º 2
0
void CeeSectionString::deleteEntries(StringTableEntry *e)
{
    if (!e)
        return;
    deleteEntries(e->m_next);
    delete e;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
	
   	queueEntry *root = getFiles();
   	printList(root);
   	deleteEntries(root);	
    return 0;
}
Ejemplo n.º 4
0
CeeSectionString::~CeeSectionString()
{
#ifdef RDATA_STATS
    dumpTable();
#endif
    for (int i=0; i < MaxRealEntries; i++)
        deleteEntries(stringTable[i]);
}
AttributesImpl::~AttributesImpl()
{
	// Clean up everything...
	clear();

	assert(m_attributesVector.empty() == true);

	deleteEntries(m_cacheVector);
}
Ejemplo n.º 6
0
// Calculate the union of two reference lists.
void MdamRefList::unionx(const MdamRefList & refList0Ref,
                         const MdamRefList & refList1Ref,
			 FixedSizeHeapManager & mdamRefListEntryHeap)
{
  // Delete all the entries from the target list.
  deleteEntries(mdamRefListEntryHeap);

  // Obtain the first disjunct number from each source list.
  Int32 disjunctNum0 = disjunctNumInitialValue;
  Int32 disjunctNum1 = disjunctNumInitialValue;
  MdamRefListIterator iterator0(&refList0Ref);
  MdamRefListIterator iterator1(&refList1Ref); 
  NABoolean more0 = iterator0(disjunctNum0);
  NABoolean more1 = iterator1(disjunctNum1);
  
  // Loop through both lists until either one is empty.
  while (more0 && more1)
    {
      if (disjunctNum0 == disjunctNum1)
        {
          // Disjunct numbers are equal.  Keep one copy.
          insert(disjunctNum0, mdamRefListEntryHeap);
          // Advance both lists.
          more0 = iterator0(disjunctNum0);
          more1 = iterator1(disjunctNum1);
        }
      else if (disjunctNum0 < disjunctNum1)
        {
          // Disjunct number from list 0 is less.
          // Insert it into the result and advance list 0. 
          insert(disjunctNum0, mdamRefListEntryHeap);
          more0 = iterator0(disjunctNum0);
        }
      else
        {
          // Disjunct number from list 1 is less.
          // Insert it into the result and advance list 1.  
          insert(disjunctNum1, mdamRefListEntryHeap);
          more1 = iterator1(disjunctNum1);
        }
    }

  // Copy any remaining disjunct numbers from refList0Ref.
  while (more0)
    {
      insert(disjunctNum0, mdamRefListEntryHeap);
      more0 = iterator0(disjunctNum0);
    }

  // Copy any remaining disjunct numbers from refList1Ref.
  while (more1)
    {
      insert(disjunctNum1, mdamRefListEntryHeap);
      more1 = iterator1(disjunctNum1);
    }
} 
Ejemplo n.º 7
0
// Calculate the intersection of two reference lists.
void MdamRefList::intersect(const MdamRefList & refList0Ref,
                            const MdamRefList & refList1Ref,
			    FixedSizeHeapManager & mdamRefListEntryHeap)
{
  // Delete all the entries from this list.
  deleteEntries(mdamRefListEntryHeap);

  // Obtain the first disjunct number from each list.
  Int32 disjunctNum0 = disjunctNumInitialValue;
  Int32 disjunctNum1 = disjunctNumInitialValue;
  MdamRefListIterator iterator0(&refList0Ref);
  MdamRefListIterator iterator1(&refList1Ref); 
  NABoolean more0 = iterator0(disjunctNum0);
  NABoolean more1 = iterator1(disjunctNum1);
  
  // Iterate finding disjunct numbers common to both lists.
  // Stop when either list is exhausted.
  while (more0 && more1)
    {
      if (disjunctNum0 == disjunctNum1)
        {
          // Disjunct numbers are equal.  Insert into result list.
          insert(disjunctNum0, mdamRefListEntryHeap);
          // Advance both lists.
          more0 = iterator0(disjunctNum0);
          more1 = iterator1(disjunctNum1);
        }
      else if (disjunctNum0 < disjunctNum1)
        {
          // Disjunct number from list 0 is less.
          // Advance list 0. 
          more0 = iterator0(disjunctNum0);
        }
      else
        {
          // Disjunct number from list 1 is less.
          // Advance list 1. 
          more1 = iterator1(disjunctNum1);
        }
    }
}
Ejemplo n.º 8
0
main() {
	int response;
	signed int iStatus = 0;

	FILE *pWrite;
	FILE *pRead;
	
	do{
		printf("\n\tPhone Book\n");
		printf("\n1\tAdd phone book entry\n");
		printf("2\tPrint phone book\n");
		printf("3\tEdit phone book\n");
		printf("4\tDelete entry in phone book\n");
		printf("5\tExit\n\n");
		printf("Select an option: ");
		scanf("%d", &response);

		if ( response == 1 ) {
			addEntry();
		}		
		else if ( response == 2 ) {
			printEntries();
		}
		else if ( response == 3 ) {
			editEntries();
		}
		else if ( response == 4 ) {
			deleteEntries();
		}
		else if (iStatus == -1 ) {
			goto ErrorHandler;
		}
	}while(response != 5);
	system("clear");
	exit(EXIT_SUCCESS); //exit program normally

	ErrorHandler:
		perror("The following error occurred");
		exit(EXIT_FAILURE); //exit program with error
} //end main
Ejemplo n.º 9
0
Timetable::~Timetable() {
    deleteEntries();
}
/** Initializes the view. */
void CBookmarkIndex::initView()
{
	//qDebug("CBookmarkIndex::initView");

	header()->hide();

	setFocusPolicy(Qt::WheelFocus);

	//d'n'd related settings
	setDragEnabled( true );
	setAcceptDrops( true );
	setDragDropMode(QAbstractItemView::DragDrop);
	viewport()->setAcceptDrops(true);
	setAutoScroll(true);
	setAutoExpandDelay(800);

	setItemsExpandable(true);
	setRootIsDecorated(true);
	setAllColumnsShowFocus(true);
	setSelectionMode(QAbstractItemView::ExtendedSelection);

	//setup the popup menu
	m_popup = new QMenu(viewport());
	m_popup->setTitle(tr("Bookmarks"));

	m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
	m_actions.changeFolder = newQAction(tr("Rename folder"),CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);

	m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
	m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
	m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
	m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);

	m_actions.deleteEntries = newQAction(tr("Remove selected items..."), CResMgr::mainIndex::deleteItems::icon, 0, this, SLOT(deleteEntries()), this);


	//fill the popup menu itself
	m_popup->addAction(m_actions.newFolder);
	m_popup->addAction(m_actions.changeFolder);
	QAction* separator = new QAction(this);
	separator->setSeparator(true);
	m_popup->addAction(separator);
	m_popup->addAction(m_actions.changeBookmark);
	m_popup->addAction(m_actions.importBookmarks);
	m_popup->addAction(m_actions.exportBookmarks);
	m_popup->addAction(m_actions.printBookmarks);
	separator = new QAction(this);
	separator->setSeparator(true);
	m_popup->addAction(separator);
	m_popup->addAction(m_actions.deleteEntries);

	//qDebug("CBookmarkIndex::initView end");
}
void CBookmarkIndex::dropEvent( QDropEvent* event ) {
    qDebug() << "CBookmarkIndex::dropEvent";

    //setState(QAbstractItemView::NoState);
    // Try to prevent annoying timed autocollapsing. Remember to disconnect before return.
    QObject::connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
    QTreeWidgetItem* item = itemAt(event->pos());
    QTreeWidgetItem* parentItem = 0;
    int indexUnderParent = 0;

    // Find the place where the drag is dropped
    if (item) {
        qDebug() << "there was item";

        QRect rect = visualItemRect(item);
        bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
        bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);

        if (isFolder) { // item is a folder
            qDebug() << "item was folder";
            if (event->pos().y() > rect.bottom() - (2* rect.height() / 3) ) {
                parentItem = item;
            }
            else {
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                qDebug() << "item:" << item << "parent:" << parentItem;
                indexUnderParent = parentItem->indexOfChild(item); // before the current folder
            }
        }
        else {
            if (isBookmark) { // item is a bookmark
                qDebug() << "item was bookmark";
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
                if (event->pos().y() > rect.bottom() - rect.height() / 2) {
                    indexUnderParent++; // after the current bookmark
                }
            }
            else { // item is the extra item
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
            }
        }

    }
    else { // no item under event point: drop to the end
        qDebug() << "there was no item";
        parentItem = invisibleRootItem();
        indexUnderParent = parentItem->childCount() - 1;
    }


    if ( event->source() == this ) {
        qDebug() << "dropping internal drag";
        event->accept();

        bool bookmarksOnly = true;
        bool targetIncluded = false;
        bool moreThanOneFolder = false;

        QList<QTreeWidgetItem*> newItems = addItemsToDropTree(parentItem, bookmarksOnly, targetIncluded, moreThanOneFolder);

        if (moreThanOneFolder) {
            QToolTip::showText(QCursor::pos(), tr("Can drop only bookmarks or one folder"));
            QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
            return;
        }
        if (targetIncluded) {
            QToolTip::showText(QCursor::pos(), tr("Can't drop folder into the folder itself or into its subfolder"));
            QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
            return;
        }
        // Ask whether to copy or move with a popup menu

        QMenu* dropPopupMenu = new QMenu(this);
        QAction* copy = dropPopupMenu->addAction(tr("Copy"));
        QAction* move = dropPopupMenu->addAction(tr("Move"));
        QAction* dropAction = dropPopupMenu->exec(QCursor::pos());
        if (dropAction == copy) {
            qDebug() << "copy";
            parentItem->insertChildren(indexUnderParent, newItems);
            // Need this here because the "move" case goes through
            // "deleteEntries" which has a save call.
            needToSaveBookmarks();
        }
        else {
            if (dropAction == move) {
                qDebug() << "move";
                parentItem->insertChildren(indexUnderParent, newItems);
                deleteEntries(false);
            }
            else {
                QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
                                    this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
                return; // user canceled
            }
        }
    }