Beispiel #1
0
void DateBookDB::removeJFEvent( const Event&ev )
{
    if ( ev.hasAlarm() )
        delEventAlarm( ev );
    if ( ev.hasRepeat() ) {
        removeRepeat( ev );
    } else {
        QValueList<Event>::Iterator it = eventList.find( ev );
        if ( it != eventList.end() )
            eventList.remove( it );
    }
}
Beispiel #2
0
void DateBookDB::reload()
{
    QValueList<Event>::Iterator it = eventList.begin();
    for ( ; it != eventList.end(); ++it ) {
        if ( (*it).hasAlarm() )
            delEventAlarm( *it );
        if ( (*it).hasRepeat() )
            removeRepeat( *it );
    }
    eventList.clear();
    repeatEvents.clear(); // should be a NOP
    init();
}
Beispiel #3
0
void DateBookDB::editEvent( const Event &old, Event &editedEv )
{
    int oldIndex=0;
    bool oldHadRepeat = old.hasRepeat();
    Event orig;

    // write to the journal...
    if ( oldHadRepeat ) {
        if ( origRepeat( old, orig ) ) // should work always...
            oldIndex = repeatEvents.findIndex( orig );
    } else
        oldIndex = eventList.findIndex( old );
    saveJournalEntry( editedEv, ACTION_REPLACE, oldIndex, oldHadRepeat );

    // Delete old event
    if ( old.hasAlarm() )
        delEventAlarm( old );
    if ( oldHadRepeat ) {
        if ( editedEv.hasRepeat() ) { // This mean that origRepeat was run above and
                                       // orig is initialized
            // assumption, when someone edits a repeating event, they
            // want to change them all, maybe not perfect, but it works
            // for the moment...
            repeatEvents.remove( orig );
        } else
            removeRepeat( old );
    } else {
        QValueList<Event>::Iterator it = eventList.find( old );
        if ( it != eventList.end() )
            eventList.remove( it );
    }

    // Add new event
    if ( editedEv.hasAlarm() )
        addEventAlarm( editedEv );
    if ( editedEv.hasRepeat() )
        repeatEvents.append( editedEv );
    else
        eventList.append( editedEv );

    d->clean = false;
}
void reverseWords(char *s) {
	int len = strlen(s);

        if(len>150)
	    return;
	int i = 0;
	char sep = ' ';
	for (i = 0; i < len - 1; i++)
	{
		if ((!in(s[i]))&&s[i]!=sep)
		{
			s[i] = sep;
		}
	}
	len = strlen(s);
	//printf("%s===%d\n", s, len);
	removeRepeat(s);  //原址去掉重复的字符串
	len = strlen(s);
	//printf("%s===%d\n", s, len);

	//去掉第一个空格
	if (s[0] == sep)
	{
		//memcpy(s,s+1,(len-1)*sizeof(char));
		myCopy(s,s+1,(len-1)*sizeof(char));
		s[len - 1] = '\0';
	}
	len = strlen(s);  //更新字符串的长度

	//printf("%s===%d\n", s, len);
	//去掉最后的空格
	if (len <= 0)
		return;
	if (s[len - 1] == sep)
	{
		s[len - 1] = '\0';
	}
	len = strlen(s);

	char mark;
	int flag = false;
	if (!in(s[len - 1]))
	{
		flag = true;
		mark = s[len - 1];
		s[len - 1] = '\0';
	}
	len = strlen(s);
	//printf("%s===%d\n",s,len);
	int maxSize = 100;
	char *str = (char*)malloc(maxSize * sizeof(char));

	int ps = 0;
	int pe = 0;
	str[0] = sep;
	int range = 0;//记录单词的长度
	int count = 0;

	for (i = 0; i < len; )
	{
		range = 0;
		//while (s[ps] != sep)
		while (s[ps] != sep&&s[ps] != '\0')
		{
			ps++;
			range++;
		}
		//ps 一直是0
		if (s[ps] == '\0')
		{
			break;
		}
		//memcpy(str+1,s,(range)*sizeof(char));
		myCopy(str+1,s,(range)*sizeof(char));
		//第一个位置被空白占了
		pe = count + range + 1;
		if ((len - pe) <= 0)
		{
			break;
		}
		//memcpy(s,s+ps+1,(len-pe)*sizeof(char));//因为多了一个空格
               myCopy (s,s+ps+1,(len-pe)*sizeof(char));//因为多了一个空格
		//memcpy(s+len-pe,str,(range+1)*sizeof(char));
		myCopy(s+len-pe,str,(range+1)*sizeof(char));
		count += range + 1;
		ps=0;
		i += range+1;
	}

	len = strlen(s);
	//去掉第一个空格
	if (s[0] == sep)
	{
		//memcpy(s, s + 1, (len - 1)*sizeof(char));
		myCopy(s, s + 1, (len - 1)*sizeof(char));
		s[len - 1] = '\0';
	}
	len = strlen(s);  //更新字符串的长度
	//printf("%s===%d\n", s, len);
	if (flag)
	{
		s[len] = mark;
		s[len + 1] = '\0';
	}
	//printf("%s===%d\n", s, len);
}