| /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| /* |
| * Copyright (c) 2012-2013 University of California, Los Angeles |
| * |
| * This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 2 as |
| * published by the Free Software Foundation; |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with this program; if not, write to the Free Software |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| * |
| * Author: Jared Lindblom <lindblom@cs.ucla.edu> |
| */ |
| |
| #include "simpleeventcatcher.h" |
| |
| SimpleEventCatcher::SimpleEventCatcher(FileSystemWatcher* watcher, QObject *parent) : |
| QObject(parent) |
| { |
| // register for directory event signal (callback function) |
| QObject::connect(watcher, SIGNAL(dirEventSignal(std::vector<sEventInfo>)), this, SLOT(handleDirEvent(std::vector<sEventInfo>))); |
| } |
| |
| void SimpleEventCatcher::handleDirEvent(std::vector<sEventInfo> dirChanges) |
| { |
| qDebug() << endl << "[SIGNAL] From SimpleEventCatcher Slot:"; |
| |
| if(!dirChanges.empty()) |
| { |
| for(size_t i = 0; i < dirChanges.size(); i++) |
| { |
| QString tempString; |
| |
| eEvent event = dirChanges[i].event; |
| QString absFilePath = QString::fromStdString(dirChanges[i].absFilePath); |
| |
| switch(event) |
| { |
| case ADDED: |
| tempString.append("ADDED: "); |
| break; |
| case MODIFIED: |
| tempString.append("MODIFIED: "); |
| break; |
| case DELETED: |
| tempString.append("DELETED: "); |
| break; |
| } |
| |
| tempString.append(absFilePath); |
| |
| qDebug() << "\t" << tempString; |
| } |
| } |
| else |
| { |
| qDebug() << "\t[EMPTY]"; |
| } |
| } |
| |
| #if WAF |
| #include "simpleeventcatcher.moc" |
| #include "simpleeventcatcher.cpp.moc" |
| #endif |