first commit of unfinished todo module

This commit is contained in:
Anselme 2015-08-24 17:42:15 +02:00
parent 1e683c05f6
commit 52eb067cd9
4 changed files with 81 additions and 2 deletions

View File

@ -15,7 +15,8 @@ SOURCES = main.cpp \
vocab.cpp \
poilaumodule.cpp \
fourasmodule.cpp \
riddles.cpp
riddles.cpp \
todomodule.cpp
HEADERS += \
regismodule.h \
@ -23,4 +24,5 @@ HEADERS += \
vocab.h \
poilaumodule.h \
fourasmodule.h \
riddles.h
riddles.h \
todomodule.h

View File

@ -31,6 +31,11 @@ bool SparrowModule::messageHandler(Message msg)
answer = say("sparrowModule v1.0");
return true;
}
else if(msg.args.compare("re", Qt::CaseInsensitive) == 0)
{
answer = say("Re");
return true;
}
else if(msg.args.startsWith("!devzone"))
{
QStringList paramList = msg.args.split(' ');

41
app/todomodule.cpp Normal file
View File

@ -0,0 +1,41 @@
#include "todomodule.h"
#include "message.h"
#include <time.h>
TodoModule::TodoModule()
{
}
bool TodoModule::messageHandler(Message msg)
{
if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) == 0)
{
if(msg.args.startsWith("!todo "))
{
Task t;
t.isPrivate = !msg.target.contains(getChan());
t.emitter = msg.nick;
t.date = time(NULL);
QStringList splitter = msg.args.split(' ');
// !todo [target] durée/date [every durée_repeat] text
// date(jour/mois-[heure[:minutes[:secondes]]])
// every day / every month / every heures[:minutes[:secondes]]
}
}
}
void TodoModule::addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate)
{
Task t;
t.date = date;
t.description = description;
t.emitter = emitter;
t.recipient = recipient;
t.repeat = repeat;
t.isPrivate = isPrivate;
tasks.push_back(t);
// TODO -> append it to save file
}

31
app/todomodule.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef TODOMODULE_H
#define TODOMODULE_H
#include "module.h"
#include <QString>
#include <vector>
class TodoModule : public Module
{
typedef struct s_task
{
unsigned long date;
unsigned long repeat;
QString description;
QString emitter;
QString recipient;
bool isPrivate;
} Task;
std::vector<Task> tasks;
public:
TodoModule();
virtual bool messageHandler(Message msg);
virtual QString getName() {return "todo";}
void addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate);
};
#endif // TODOMODULE_H