Exemplo n.º 1
0
QModelIndex ChannelsModel::parent ( const QModelIndex & index ) const
{
    Q_ASSERT(index.isValid());
    if(index.internalId() & CHANNEL_ITEM)
    {
        int channelid = (index.internalId() & ITEM_DATA);
        mchannels_t::const_iterator p_ite = m_channelparent.find(channelid);
        Q_ASSERT(p_ite != m_channelparent.end());
        int parentid = p_ite.value();
        channels_t::const_iterator chan_ite = m_channels.find(parentid);
        if(chan_ite == m_channels.end() || parentid == 0)
            return QModelIndex();
        int row = getRowNumber(parentid);
        Q_ASSERT(row>=0);
        return createIndex(row, 0, parentid | CHANNEL_ITEM);
    }

    if(index.internalId() & USER_ITEM)
    {
        int userid = (index.internalId() & ITEM_DATA);
        musers_t::const_iterator p_ite = m_userparent.find(userid);
        Q_ASSERT(p_ite != m_userparent.end());
        int parentid = p_ite.value();
        int row = getRowNumber(parentid);
        Q_ASSERT(row>=0);
        return createIndex(row, 0, parentid | CHANNEL_ITEM);
    }
    return QModelIndex();
}
Exemplo n.º 2
0
//==========================================
void histogram(int sid)
//==========================================
{
    int i,j,k=0,temp,height = g_rows - 1;
    int color=0,div,rscale = 0,rn1,rn2;
    char sstr[40];
    
    float fx = readLatestSidValue(sid,g_mid);
    // Get max and min value
    g_fmax = 0.;
    g_fmin = 999999.;
    for(i=1;i<=g_cols-5;i++)
    {
         g_fbuff[i] = g_fbuff[i+1];
         if(g_fmin > g_fbuff[i])g_fmin = g_fbuff[i];
         if(g_fmax < g_fbuff[i])g_fmax = g_fbuff[i];
    }
    g_fmax = g_fmax*1.1;
    
    g_fbuff[g_cols-5] = fx;
    
    div = getDivision(g_fmax);
    
    k=1;
    int kindex = div;
    for(j=1;j<=g_rows;j++)
    {
        if(j == getRowNumber(g_fmax,kindex))
        {
            writeInt(kindex,1, j, C_BLUE);
            writeInt(kindex,g_cols-4, j, C_BLUE);
            k++;
            kindex = k*div;
        }
    }
    

    rn1 = getRowNumber(g_fmax,3000.);
    rn2 = getRowNumber(g_fmax,1000.);
    //writeFloat(g_fmax,7,g_rows-1, 0);
    sprintf(sstr,"%d Watt",(int)fx);
    //writeFloat(fx,g_cols/2,g_rows-1, C_RED);
    writeString(sstr,g_cols/2,g_rows-1, C_RED);
 
    g_fmin = 0.0;
    for(i=1;i<=g_cols-5;i++)
    {
         if(g_fmax > 0)temp = (int)(height*(g_fbuff[i]-g_fmin)/(g_fmax - g_fmin));  
         for(j=1;j<=temp;j++) 
         {
            if (j >= rn1)color = C_YELLOW;
            else if (j >= rn2)color = C_RED;
            if (j < rn2)color = C_GREEN;
            setElement('*',i,j,color);
         }
    }
}
Exemplo n.º 3
0
bool ClipboardModel::move(int pos, int newpos)
{
    int from = getRowNumber(pos,true);
    int to   = getRowNumber(newpos,true);

    if( from == -1 || to == -1 )
        return false;
    if ( !beginMoveRows(emptyIndex, from, from, emptyIndex,
                        from < to ? to+1 : to) )
        return false;
    m_clipboardList.move(from, to);
    endMoveRows();
    return true;
}
Exemplo n.º 4
0
bool ClipboardModel::move(int pos, int newpos)
{
    int from = getRowNumber(pos,true);
    int to   = getRowNumber(newpos,true);

    if( from == -1 || to == -1 )
        return false;

    const int sourceRow = from;
    const int targetRow = to;
    if (from < to)
        ++to;

    if ( !beginMoveRows(QModelIndex(), from, from, QModelIndex(), to) )
        return false;

    m_clipboardList.move(sourceRow, targetRow);

    endMoveRows();

    return true;
}
Exemplo n.º 5
0
int MaIterator::getStep(qint64 position) const {
    CHECK(!coreRegionsOnly, 1);
    SAFE_POINT(isInRange(position), "Out of boundaries", 1);
    const int rowNumber = getRowNumber(position);
    const int columnNumber = getColumnNumber(position);
    const MultipleAlignmentRow row = ma->getRow(rowsIndexes[rowNumber]);
    CHECK(!row->isTrailingOrLeadingGap(columnNumber), 1);
    switch (direction) {
    case Forward:
        return row->getCoreEnd() <= columnNumber ? ma->getLength() - columnNumber : 1;
        break;
    case Backward:
        return row->getCoreStart() >= columnNumber ? ma->getLength() - columnNumber : 1;
        break;
    default:
        FAIL("An unknown direction", 1);
    }
}
enum KeypadButton KeypadController::buttonPressed(int col)
{
    enum KeypadButton button = KEY_NONE;

    sendToKeypad("@00P1?\r");

    if (response[0] != '!')
    {
        qWarning() << "Bad Response";
    }
    else if (strncmp(response,"!00F0", 5) != 0)
    {
        // something was pressed
        int row = getRowNumber(&response[4]);
        button = getButton(row, col);
    }
    // qDebug() << response;
 //   printf("message %c%c%c%c%c\n", buf[0],buf[1],buf[2],buf[3],buf[4]);
//	getchar();
    return button;
}
Exemplo n.º 7
0
QPoint MaIterator::getMaPoint() const {
    SAFE_POINT(isInRange(position), "Out of boundaries", QPoint(-1, -1));
    return QPoint(getColumnNumber(position), getRowNumber(position));
}