Esempio n. 1
0
void TaskPacker::findDateAndTime(int index) {
	_chronoInterpreter->interpretDateAndTime(_tokens, index);
	findTime(index);
	findDate(index);

	return;
}
Esempio n. 2
0
bool rulesSystem::isBlackout(string date)
{
  
  //Since findDate returns a -1 if it is not on the list, this is
  //an easy thing to check for
  
  return (findDate(date) != -1);
  
}
Esempio n. 3
0
bool rulesSystem::removeBlackout(string blackoutDate)
{
  
  int position = findDate(blackoutDate);
  
  if (position != -1 && !m_blackout.empty()) {
	
      //Since begin() will start at 0, position needs to be
      //decremented to erase the proper entry

      //position -= 1;

      m_blackout.erase(m_blackout.begin() + position);
      
      //Good escape because it was erased
      
      return true;
    
  }
  
  //Not found, so no remove
  return false;
  
}
Esempio n. 4
0
bool Connector::copyFile(QString fileName, QIODevice *target, uint &size, QDateTime &lastModified, bool infoOnly){
    QByteArray content;
    QStringList infos;
    QRegExp findBytes("([0-9]+)B");
    QRegExp findDate("([0-9]+)");

    this->_socket->write("exportfile\n");
    this->_socket->waitForReadyRead();
    this->_socket->readAll();
    this->_socket->write(fileName.toUtf8() + "\n");
    this->_socket->waitForReadyRead();

    //Metadaten einlesen
    infos = QString::fromUtf8(this->_socket->readAll()).split("\n");

    if(infos.last().contains("@")){
        return false;
    }


    findBytes.indexIn(infos.at(0));
    findDate.indexIn(infos.at(1));
    lastModified.setTime_t(QVariant(findDate.capturedTexts().at(1)).toUInt());
    size = QVariant(findBytes.capturedTexts().at(1)).toUInt();



    //Nur Metadaten?
    if(infoOnly){
        this->_socket->write("n\n");
        this->_socket->waitForReadyRead();
        return true;
    }



    //Kopieren
    this->_socket->write("y\n");
    content = this->_socket->readAll();


    uint done = 0;
    while(!content.contains("\n")){
        done += content.length();

        emit copyFileProgress(fileName,done,size);
        if(content.length()%2 == 0){
            target->write(QByteArray::fromHex(content));
            content = QByteArray();
        }else{
            target->write(QByteArray::fromHex(content.left(content.length()-1)));
            content = content.right(1);
        }
        this->_socket->waitForReadyRead(100);
        qApp->processEvents(QEventLoop::AllEvents,100);

        content += this->_socket->readAll();
    }

    content = content.replace("\nEND\n","\n");
    target->write(QByteArray::fromHex(content.left(content.indexOf("\n"))));

    emit copyFileProgress(fileName,size,size);

    return true;
}
bool LogicDetailParser::parser(Task& task, string text, string operation){
	int dateCheck;
	int timeCheck;
	string tempDate;
	string lowercaseText = textChangeLowercase(text);

	_hoursFlag = false;
	_taskDescription = text;
	_time = CANNOTFIND;
	_date = CANNOTFIND;

	getIndicators(lowercaseText);

	if(_slashPosition == NOTSTATED && _hrsPosition == NOTSTATED &&
		_dotPosition == NOTSTATED && _colonPosition == NOTSTATED &&
		_amPosition == NOTSTATED && _pmPosition == NOTSTATED){
			task.setTaskDescription(text);
			return true;
	}

	if(_slashPosition != NOTSTATED){
		dateCheck = findDate(task, lowercaseText);
		if(dateCheck == ERROR)
			return false;
		else if(dateCheck == FOUND){
			tempDate = _date;
			_taskDescription = trimFoundText(_taskDescription, _date);

			lowercaseText = textChangeLowercase(_taskDescription);
			getIndicators(lowercaseText);

			dateCheck = findDate(task, lowercaseText);
			if(dateCheck == ERROR)
				return false;
			else if(dateCheck == FOUND)
				_taskDescription = trimFoundText(_taskDescription, _date);
			else if(dateCheck == NOTFOUND)
				setTaskDate(task, task.getStartDay(), task.getStartMonth(), task.getStartYear());
		}
	}
	_date = tempDate;

	if(!findTime(task, textChangeLowercase(text)))
		return false;

	removeUnwantedText();
	if(_taskDescription.size() != POINTZERO)
		task.setTaskDescription(_taskDescription);

	if(operation == "change"){
		if(task.getStartDay() == task.getEndDay() && _hoursFlag)
			task.setEndDay(task.getStartDay() + POINTONE);
		return true;
	}

	if(operation == "add"){
		if(task.getStartDay() == task.getEndDay() && _hoursFlag)
			task.setEndDay(task.getStartDay() + POINTONE);

		if (_time != CANNOTFIND && _date != CANNOTFIND){}
		else if (_time == CANNOTFIND){
			task.setStartTime(900);
			task.setEndTime(1800);
		}
		else if (_date == CANNOTFIND)
			setDate(task);
		else
			//floating
			return false;
	}
}