예제 #1
0
void OSDPlugin::processQueue()
{
    if (m_timer->isActive())
        return;
    while (queue.size()){
        m_request = queue.front();
        QString text;
        Contact *contact = getContacts()->contact(m_request.contact);
        OSDUserData *data = NULL;
        if (contact){
            data = (OSDUserData*)contact->getUserData(user_data_id);
            if (m_request.type){
                if (data->EnableMessage && core){
                    unsigned type = m_request.type;
                    for (;;){
                        CommandDef *cmd = core->messageTypes.find(type);
                        if (cmd == NULL)
                            break;
                        MessageDef *def = (MessageDef*)(cmd->param);
                        if (def->base_type){
                            type = def->base_type;
                            continue;
                        }
                        text = i18n(def->singular, def->plural, 1);
                        text = i18n("%1 from %2")
                               .arg(text)
                               .arg(contact->getName());
                        break;
                    }
                }
            }else{
                if (data->EnableAlert)
                    text = i18n("%1 is online") .arg(contact->getName());
            }
        }
        if (!text.isEmpty()){
            if (m_osd == NULL){
                m_osd = new OSDWidget;
                connect(m_osd, SIGNAL(dblClick()), this, SLOT(dblClick()));
            }
            static_cast<OSDWidget*>(m_osd)->showOSD(text, data);
            m_timer->start(data->Timeout * 1000);
            queue.erase(queue.begin());
            break;
        }
        queue.erase(queue.begin());
    }
}
예제 #2
0
CloudTableView::CloudTableView(int modelNum)
{
    cs=0;
    CTModel=0;
    myProxyModel = new MySortFilterProxyModel();
    myProxyModel->setDynamicSortFilter(true);
 //   myProxyModel->setFilterKeyColumn(0);

    initModel(modelNum);
    this->setSortingEnabled(true);
    this->sortByColumn(0,Qt::AscendingOrder);




    installEventFilter(this);   // event filter for using keyboard


    connect(this,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(dblClick(QModelIndex)));
    //    connect(this,SIGNAL(activated(QModelIndex)),this,SLOT(verticalScrollbarValueChanged(int)));
    //    connect(this,SIGNAL(entered(QModelIndex)),this,SLOT(qTest()));

    this->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(sheetContextMenu(const QPoint &)));

    //Reimplement signal from QWidget
    connect(this,SIGNAL(focusOutEvent(QFocusEvent*)),this,SLOT(outOfFocusHappend()));

}
예제 #3
0
void OSDWidget::mouseDoubleClickEvent(QMouseEvent*)
{
    emit dblClick();
}
예제 #4
0
void OSDPlugin::processQueue()
{
    if (m_timer->isActive())
        return;
    while (queue.size()){
        m_request = queue.front();
        queue.erase(queue.begin());
        Contact *contact = getContacts()->contact(m_request.contact);
        if ((contact == NULL) || contact->getIgnore()){
            continue;
        }
        QString text;
        OSDUserData *data = NULL;
        data = (OSDUserData*)contact->getUserData(user_data_id);
        switch (m_request.type){
        case OSD_ALERT:
            if (data->EnableAlert.bValue){
                unsigned style = 0;
                const char *statusIcon = NULL;
                if (contact->contactInfo(style, statusIcon) >= STATUS_ONLINE)
                    text = g_i18n("%1 is online", contact) .arg(contact->getName());
            }
            break;
        case OSD_TYPING:
            if (data->EnableTyping.bValue){
                unsigned style = 0;
                string wrkIcons;
                const char *statusIcon = NULL;
                contact->contactInfo(style, statusIcon, &wrkIcons);
                bool bTyping = false;
                while (!wrkIcons.empty()){
                    if (getToken(wrkIcons, ',') == "typing"){
                        bTyping = true;
                        break;
                    }
                }
                if (bTyping)
                    text = g_i18n("%1 is typing", contact) .arg(contact->getName());
            }
            break;
        case OSD_MESSAGE:
            if (data->EnableMessage.bValue && core){
                list<msg_id>::iterator it;
                TYPE_MAP types;
                TYPE_MAP::iterator itc;
                QString msg_text;
                for (it = core->unread.begin(); it != core->unread.end(); ++it){
                    if ((*it).contact != m_request.contact)
                        continue;
                    unsigned type = (*it).type;
                    itc = types.find(type);
                    if (itc == types.end()){
                        types.insert(TYPE_MAP::value_type(type, 1));
                    }else{
                        (*itc).second++;
                    }
                    if (!data->EnableMessageShowContent.bValue)
                        continue;
                    MessageID id;
                    id.id      = (*it).id;
                    id.contact = (*it).contact;
                    id.client  = (*it).client.c_str();
                    Event e(EventLoadMessage, &id);
                    Message *msg = (Message*)(e.process());
                    if (msg == NULL)
                        continue;
                    QString msgText = msg->getPlainText().stripWhiteSpace();
                    if (msgText.isEmpty())
                        continue;
                    if (!msg_text.isEmpty())
                        msg_text += "\n";
                    msg_text += msgText;
                }
                if (types.empty())
                    break;
                for (itc = types.begin(); itc != types.end(); ++itc){
                    CommandDef *def = core->messageTypes.find((*itc).first);
                    if (def == NULL)
                        continue;
                    MessageDef *mdef = (MessageDef*)(def->param);
                    QString msg = i18n(mdef->singular, mdef->plural, (*itc).second);
                    if ((*itc).second == 1){
                        int pos = msg.find("1 ");
                        if (pos > 0){
                            msg = msg.left(pos);
                        }else if (pos == 0){
                            msg = msg.mid(2);
                        }
                        msg = msg.left(1).upper() + msg.mid(1);
                    }
                    if (!text.isEmpty())
                        text += ", ";
                    text += msg;
                }
                text = i18n("%1 from %2") .arg(text) .arg(contact->getName());
                if (msg_text.isEmpty())
                    break;
                text += ":\n";
                text += msg_text;
            }
        }
        if (!text.isEmpty()){
            if (m_osd == NULL){
                m_osd = new OSDWidget;
                connect(m_osd, SIGNAL(dblClick()), this, SLOT(dblClick()));
				connect(m_osd, SIGNAL(closeClick()), this, SLOT(timeout()));
            }
            static_cast<OSDWidget*>(m_osd)->showOSD(text, data);
            m_timer->start(data->Timeout.value * 1000);
            return;
        }
    }
    m_timer->stop();
    m_request.contact = 0;
    m_request.type = OSD_NONE;
}