Example #1
0
void MainWindow::dial_customer(const QPoint& pos)
{
    QPoint globalPos = ui->tableCustomers->mapToGlobal(pos);
            //myWidget->mapToGlobal(pos);
    // for QAbstractScrollArea and derived classes you would use:
    // QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);

    QMenu myMenu;
    myMenu.setFocusPolicy(Qt::NoFocus);
    myMenu.addAction(trUtf8("Κλήση πελάτη"));
    // ...

    QAction* selectedItem = myMenu.exec(globalPos);

    QString phone;
    if (selectedItem)
    {
        QSqlQuery query(db1);
        QString c_id=customer_model->data(customer_model->index(ui->tableCustomers->currentIndex().row(),0)).toString();
        query.exec("select phone from customers where id="+c_id);
        query.next();
        phone=query.value(0).toString();
        dial(phone);
    }



}
Example #2
0
void MainWindow::context_menu_full_calls(const QPoint &pos)
{
    QPoint globalPos = ui->tableAllCalls->mapToGlobal(pos);


    QMenu myMenu;
    myMenu.setFocusPolicy(Qt::NoFocus);
    myMenu.addAction(trUtf8("Κλήση πελάτη"));


    QAction* selectedItem = myMenu.exec(globalPos);

    QString phone;
    if (selectedItem)
    {
        QString src=full_calls_model->data(full_calls_model->index(ui->tableAllCalls->currentIndex().row(),1)).toString();
        QString dst=full_calls_model->data(full_calls_model->index(ui->tableAllCalls->currentIndex().row(),2)).toString();
        if (src.length()>dst.length())
            phone=src;
        else
            phone=dst.mid(1,15);

        dial(phone);
    }

}
Example #3
0
void MainWindow::context_menu(const QPoint& pos)
{
    // for most widgets
       QPoint globalPos = ui->tableView->mapToGlobal(pos);
               //myWidget->mapToGlobal(pos);
       // for QAbstractScrollArea and derived classes you would use:
       // QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);

       QMenu myMenu;
       myMenu.setFocusPolicy(Qt::NoFocus);
       myMenu.addAction(trUtf8("Συνέχιση εργασίας"));

       myMenu.addAction(trUtf8("Kλήση πελάτη"));
       // ...

       QAction* selectedItem = myMenu.exec(globalPos);
       if (selectedItem)
       {

           QSqlQuery query(db1);
           QString t_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
           query.exec("select t.cusid,t.placeid,t.projectid,t.comment from tasks t where id="+t_id);
           query.next();
           this->cusid=query.value(0).toString();
           QString t_cusid=cusid=query.value(0).toString();

           if(selectedItem->text()==trUtf8("Συνέχιση εργασίας"))
           {

           refresh_places();
           refresh_projects();

           ui->label_customer->setText(tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),1)).toString());
           ui->textEdit->setPlainText(query.value(3).toString());
           for (int i=0;i<ui->comboplace->count();++i)
           {
               ui->comboplace->setCurrentIndex(i);

               if (places_model->data(places_model->index(ui->comboplace->currentIndex(),0))==query.value(1).toInt())

                   break;

           }
           for (int i=0;i<ui->comboproject->count();++i)
           {
               ui->comboproject->setCurrentIndex(i);

               if (project_model->data(project_model->index(ui->comboproject->currentIndex(),0))==query.value(2).toInt())

                   break;

           }
           ui->pushHour->setEnabled(TRUE);
           }
           else
           {
               query.exec("select phone from customers where id="+t_cusid);
               query.next();
               QString phone=query.value(0).toString();
               dial(phone);

           }

       }

       return;

}