Jared Lindblom | d5ba95f | 2013-01-12 22:50:09 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012-2013 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Jared Lindblom <lindblom@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "simpleeventcatcher.h" |
| 22 | |
| 23 | SimpleEventCatcher::SimpleEventCatcher(FileSystemWatcher* watcher, QObject *parent) : |
| 24 | QObject(parent) |
| 25 | { |
| 26 | // register for directory event signal (callback function) |
| 27 | QObject::connect(watcher, SIGNAL(dirEventSignal(std::vector<sEventInfo>)), this, SLOT(handleDirEvent(std::vector<sEventInfo>))); |
| 28 | } |
| 29 | |
| 30 | void SimpleEventCatcher::handleDirEvent(std::vector<sEventInfo> dirChanges) |
| 31 | { |
| 32 | qDebug() << endl << "[SIGNAL] From SimpleEventCatcher Slot:"; |
| 33 | |
| 34 | if(!dirChanges.empty()) |
| 35 | { |
| 36 | for(size_t i = 0; i < dirChanges.size(); i++) |
| 37 | { |
| 38 | QString tempString; |
| 39 | |
| 40 | eEvent event = dirChanges[i].event; |
| 41 | QString absFilePath = QString::fromStdString(dirChanges[i].absFilePath); |
| 42 | |
| 43 | switch(event) |
| 44 | { |
| 45 | case ADDED: |
| 46 | tempString.append("ADDED: "); |
| 47 | break; |
| 48 | case MODIFIED: |
| 49 | tempString.append("MODIFIED: "); |
| 50 | break; |
| 51 | case DELETED: |
| 52 | tempString.append("DELETED: "); |
| 53 | break; |
| 54 | } |
| 55 | |
| 56 | tempString.append(absFilePath); |
| 57 | |
| 58 | qDebug() << "\t" << tempString; |
| 59 | } |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | qDebug() << "\t[EMPTY]"; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | #if WAF |
| 68 | #include "simpleeventcatcher.moc" |
| 69 | #include "simpleeventcatcher.cpp.moc" |
| 70 | #endif |