continued working on todo module
This commit is contained in:
		
							parent
							
								
									52eb067cd9
								
							
						
					
					
						commit
						085d5cd193
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -7,3 +7,4 @@ release/*
 | 
				
			|||||||
Makefile
 | 
					Makefile
 | 
				
			||||||
ui_*
 | 
					ui_*
 | 
				
			||||||
bin/*
 | 
					bin/*
 | 
				
			||||||
 | 
					build*
 | 
				
			||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
#include "todomodule.h"
 | 
					#include "todomodule.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TodoModule::TodoModule()
 | 
					TodoModule::TodoModule()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -13,18 +14,48 @@ bool TodoModule::messageHandler(Message msg)
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if(msg.args.startsWith("!todo "))
 | 
					        if(msg.args.startsWith("!todo "))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            answer = usage(TODO);
 | 
				
			||||||
            Task t;
 | 
					            Task t;
 | 
				
			||||||
 | 
					            int deltaIndex = 1;
 | 
				
			||||||
            t.isPrivate = !msg.target.contains(getChan());
 | 
					            t.isPrivate = !msg.target.contains(getChan());
 | 
				
			||||||
            t.emitter = msg.nick;
 | 
					            t.emitter = msg.nick;
 | 
				
			||||||
            t.date = time(NULL);
 | 
					            t.date = time(NULL);
 | 
				
			||||||
            QStringList splitter = msg.args.split(' ');
 | 
					            QStringList splitter = msg.args.split(' ');
 | 
				
			||||||
            // !todo [target] durée/date [every durée_repeat] text
 | 
					            if(splitter[deltaIndex].compare("to") == 0)
 | 
				
			||||||
            // date(jour/mois-[heure[:minutes[:secondes]]])
 | 
					            {
 | 
				
			||||||
            // every day / every month / every heures[:minutes[:secondes]]
 | 
					                deltaIndex += 2;
 | 
				
			||||||
 | 
					                t.emitter = splitter[2];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(splitter.size() < deltaIndex+2)
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            QString dateString = splitter[deltaIndex];
 | 
				
			||||||
 | 
					            if(dateString.startsWith("date("))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //t.date += dateString;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString TodoModule::usage(int type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch(type)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    case TODO:
 | 
				
			||||||
 | 
					        return say("usage = !todo [to TARGET] DATE | DURATION [every DURATION] DESCRIPTION");
 | 
				
			||||||
 | 
					    case DURATION:
 | 
				
			||||||
 | 
					        return say("DURATION = HOURS[:MINUTES[:SECONDS]]");
 | 
				
			||||||
 | 
					    case DATE:
 | 
				
			||||||
 | 
					        return say("DATE = date(DAY/MONTH-[HOUR[:MINUTE[:SECOND]]])");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TodoModule::addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate)
 | 
					void TodoModule::addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate)
 | 
				
			||||||
 | 
				
			|||||||
@ -19,6 +19,9 @@ class TodoModule : public Module
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    std::vector<Task> tasks;
 | 
					    std::vector<Task> tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    enum {TODO, DURATION, DATE};
 | 
				
			||||||
 | 
					    QString usage(int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    TodoModule();
 | 
					    TodoModule();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user