QVariant VKVisualMessageModel::data(const QModelIndex &index, int role) const {
    if (index.row() < 0 || index.row() >= rowCount()) {
        qDebug()<<"index is out of range"<<index.row()<<"row count"<<rowCount();
        return QVariant();
    }

    auto& obj = m_messages[index.row()];

    switch (role) {
    case eRoleActionMessages:
        return processAction(obj.message());
    case eRoleChatId:
        return obj.message()->chatId();
    case eRoleDate:
        return processDate(obj.message()->date());
    case eRoleIcon:
        return obj.message()->user()->iconSmall();
    case eRoleId:
        return obj.message()->id();
    case eRoleIncoming:
        return obj.message()->isIncoming();
    case eRoleIsRead:
        return obj.message()->isRead();
    case eRoleMsg:
        return obj.message()->body();
    case eRoleUserName:
        return obj.message()->user()->userName();
    default: {
        if (obj.contain(role)) {
            return obj.data(role);
        }
    }
    }
    return QVariant();
}
void CMessageTemplate::processMacro( LPCSTR str, int len, int fill, IWriteSink & f )
{
  if ( FarSF::LStricmp( str, M_SUBJECT ) == 0 )
    processSubject( len, fill, f );
  else if ( FarSF::LStricmp( str, M_FROM ) == 0 )
    processFrom( len, fill, f );
  else if ( FarSF::LStricmp( str, M_TO ) == 0 )
    processTo( len, fill, f );
  else if ( FarSF::LStricmp( str, M_DATE ) == 0 )
    processDate( len, fill, f );
  else if ( FarSF::LStricmp( str, M_ORGANIZATION ) == 0 )
    processOrganization( len, fill, f );
  else if ( FarSF::LStricmp( str, M_MAILER ) == 0 )
    processMailer( len, fill, f );
  else if ( FarSF::LStricmp( str, M_OSUBJECT ) == 0 )
    processOSubject( len, fill, f );
  else if ( FarSF::LStricmp( str, M_MESSAGEID ) == 0 )
    processMessageId( len, fill, f );
  else if ( FarSF::LStricmp( str, M_FROM_NAME ) == 0 )
    processFromName( len, fill, f );
  else if ( FarSF::LStricmp( str, M_FROM_ADDR ) == 0 )
    processFromAddr( len, fill, f );
  else if ( FarSF::LStricmp( str, M_TO_NAME ) == 0 )
    processToName( len, fill, f );
  else if ( FarSF::LStricmp( str, M_TO_ADDR ) == 0 )
    processToAddr( len, fill, f );
  else if ( FarSF::LStricmp( str, M_SENT_DATE ) == 0 )
    processSentDate( len, fill, f );
  else if ( FarSF::LStricmp( str, M_SENT_TIME ) == 0 )
    processSentTime( len, fill, f );
  else if ( FarSF::LStricmp( str, M_RECEIVED_DATE ) == 0 )
    processReceivedDate( len, fill, f );
  else if ( FarSF::LStricmp( str, M_RECEIVED_TIME ) == 0 )
    processReceivedTime( len, fill, f );
  else if ( FarSF::LStricmp( str, M_TEXT ) == 0 )
    processText( len, f );
  else if ( FarSF::LStricmp( str, M_HEADERS ) == 0 )
    processHeaders( f );
  else if ( FarSF::LStrnicmp( str, M_KLUDGE, strlen(M_KLUDGE) ) == 0 )
  {
    str += _countof(M_KLUDGE);

    while ( *str && ( isspace( (unsigned char)*str ) || *str == '(' ||
      *str == '\"' || *str == '\'' ) ) str ++;

    if ( *str )
    {
      LPCSTR end = str + 1;

      while ( *end && !isspace( (unsigned char)*end ) && *end != ')' &&
        *end != '\"' && *end != '\'' ) end ++;

      processKludge( FarString( str, end - str ), f );
    }
  }
}
Beispiel #3
0
static
void PrintTestList(My402List *pList, int num_items)
{
    My402ListElem *elem=NULL;
	int i=0,bal=0;
	Transact *x;
	printf("+-----------------+--------------------------+----------------+----------------+\n");
	printf("|       Date      | Description              |         Amount |        Balance |\n");
	printf("+-----------------+--------------------------+----------------+----------------+\n");
		
	
    if (My402ListLength(pList) != num_items)
	{
        fprintf(stderr, "List length is not %1d in PrintTestList().\n", num_items);
        exit(1);
    }
    for (elem=My402ListFirst(pList); elem != NULL; elem=My402ListNext(pList, elem),i++)
	{//Transact *x;
		x=(Transact*)elem->obj;
		char op=(char)(x->op);
		long time=(long)(x->ltime);
        int amt=(int)(x->amt);
		char *desc=x->desc;
		char t[24],amount[15],balance[15];
		strcpy(t,ctime(&time));
		
		char fintime[15];
		strcpy(fintime,processDate(t));
		//int i;
		if(op=='+')
		{
			bal=bal+amt;
		}
		else
		{
			bal=bal-amt;
		}
		
		strcpy(amount,processNum(amt));
		strcpy(balance,processNum(bal));
		
		//printf("%lu\t",(long)(((Transact*)(elem->obj))->ltime));
		// printf("%c\t%lu\t%d\t%s\n",op,time,amt,desc);
      
//	  printf("|%lu\t%s\t\t%0.2f\t%0.2f\n",time,desc,amount,balance);
	if(op=='-')
		printf("| %s | %-24s | (%12s) | %14s |\n",b,desc,amount,balance);
	else
		printf("| %s | %-24s | %14s | %14s |\n",b,desc,amount,balance);
		//printf("FINTIME %s",fintime);
    }
	printf("+-----------------+--------------------------+----------------+----------------+");
	
    fprintf(stdout, "\n");
}
/**
 * Gets called when the name box is selected. Displays a list of names for the
 * client to choose in order to filter the graphing.
 *
 */
void Summary::on_nameBox_activated(int index)
{
        FieldMatchFilter nameMatch(MEMBER_NAME, "");
        vector<grantsAndFundingField> nameFields;;
        vector<vector<string>> nameResults;
        vector<Filter*> filters;

        int earliest = ui->lineEdit->text().toInt();
        int latest = ui->lineEdit_2->text().toInt();
        if(latest == 0){
            time_t t = std::time(0);
            struct tm * now = localtime(&t);
            earliest = 1970;
            latest = now->tm_year + 1900;
            ui->lineEdit->setText(QString::number(earliest));
            ui->lineEdit_2->setText(QString::number(latest));
        }
        DateFilter df(earliest,latest);
        filters.push_back(&df);
        filters = chosenName(filters, &nameMatch);

        if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Pub",Qt::CaseInsensitive) == true){
            nameFields.push_back(STATUS_DATE);
            db.getPublications(nameResults,filters,nameFields);
        }
        else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Grant",Qt::CaseInsensitive) == true){
            nameFields.push_back(START_DATE);
            db.getGrantsAndFunding(nameResults,filters,nameFields);

        }
        else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Pres",Qt::CaseInsensitive) == true){
            nameFields.push_back(DATES);
            db.getPresentations(nameResults,filters,nameFields);
        }
        else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Teach",Qt::CaseInsensitive) == true){
            nameFields.push_back(START_DATE);
            db.getTeaching(nameResults,filters,nameFields);
        }

        processDate(nameResults);
        graphs();
    graphs();
}
void DateValidator::processItem(LedgerTransaction const& transaction)
{
   processDate(transaction.date(), transaction.fileName(),
               transaction.lineNum());
}
void DateValidator::processItem(LedgerBudget const& budget)
{
   processDate(budget.date(), budget.fileName(), budget.lineNum());
}
void DateValidator::processItem(LedgerAccountCommand const& account)
{
   processDate(account.date(), account.fileName(), account.lineNum());
}
void DateValidator::processItem(LedgerAccountBalance const& balance)
{
   processDate(balance.date(), balance.fileName(), balance.lineNum());
}