Exemplo n.º 1
0
void MainWindow::add_earlier_task()
{

    tasks *w=new tasks(this,&db1,"0",0);
    connect(w,SIGNAL(refresh_tasks()),this,SLOT(refresh_tasks()));
    connect(w,SIGNAL(refresh_tasks()),this,SLOT(refresh_full_tasks()));
    w->show();
}
Exemplo n.º 2
0
void MainWindow::edit_task_full()
{
    QString tk_id=tasks_full_model->data(tasks_full_model->index(ui->tableView_2->currentIndex().row(),0)).toString();
    tasks *w=new tasks(this,&db1,tk_id,1);
    connect(w,SIGNAL(refresh_tasks()),this,SLOT(refresh_tasks()));
    connect(w,SIGNAL(refresh_tasks()),this,SLOT(refresh_full_tasks()));
    w->show();
}
tasks_map_ptr tasks_monitor_impl::active_tasks()
{
    m_stamp++;

    tasks_refresh_list tl;
    refresh_tasks( tl );
    update_tasks_map( tl );

    return m_tasks;
}
Exemplo n.º 4
0
static void
past_due_color_changed_cb (GtkColorButton *color_button, GUI *appGUI)
{
	GdkColor color;

	gtk_color_button_get_color (color_button, &color);
	g_snprintf (config.past_due_color, MAXCOLORNAME, "#%02X%02X%02X",
	            color.red * 256 / 65536, color.green * 256 / 65536, color.blue * 256 / 65536);
	refresh_tasks (appGUI);
}
Exemplo n.º 5
0
void
past_due_color_changed_cb (GtkColorButton *widget, gpointer user_data) {

gchar tmpbuf[BUFFER_SIZE];
GdkColor color;

    GUI *appGUI = (GUI *)user_data;

    gtk_color_button_get_color(GTK_COLOR_BUTTON(appGUI->opt->past_due_color_picker), &color);
    sprintf(tmpbuf, "#%02X%02X%02X", color.red * 256 / 65536, color.green * 256 / 65536, color.blue * 256 / 65536);
    strncpy(config.past_due_color, tmpbuf, MAXCOLORNAME-1);
    refresh_tasks (appGUI);

}
Exemplo n.º 6
0
static void
tasks_category_remove_cb (GtkWidget *widget, GUI *appGUI)
{
	GtkTreePath *path;
	GtkTreeIter iter;

	gtk_tree_view_get_cursor (GTK_TREE_VIEW (appGUI->opt->tasks_category_treeview), &path, NULL);

	if (path != NULL) {
		gtk_tree_model_get_iter (GTK_TREE_MODEL (appGUI->opt->tasks_category_store), &iter, path);
		gtk_list_store_remove (appGUI->opt->tasks_category_store, &iter);
		gtk_tree_path_free (path);
		refresh_tasks (appGUI);
	}
}
Exemplo n.º 7
0
static void
tsk_show_in_tasks_list_toggled (GtkCellRendererToggle *cell, gchar *path_str, GUI *appGUI)
{
	GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeIter iter;
	gboolean done_status;

	model = GTK_TREE_MODEL (appGUI->opt->tasks_category_store);
	path = gtk_tree_path_new_from_string (path_str);

	if (path != NULL) {
		gtk_tree_model_get_iter (model, &iter, path);   /* get toggled iter */
		gtk_tree_model_get (model, &iter, TC_COLUMN_TASKS, &done_status, -1);
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, TC_COLUMN_TASKS, !done_status, -1);
		refresh_tasks (appGUI);
		gtk_tree_path_free (path);
	}
}
Exemplo n.º 8
0
void MainWindow::delete_clicked()
{
    QString tk_id;
    if (current_tab==2)
    {
        //tk_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
    //else
        tk_id=tasks_full_model->data(tasks_full_model->index(ui->tableView_2->currentIndex().row(),0)).toString();

    QMessageBox m;
    m.setText(trUtf8("Θέλετε να διαγράψετε την επιλεγμένη κίνηση"));
    m.setInformativeText(trUtf8("ΠΡΟΣΟΧΗ!!!"));
    QAbstractButton *acc = m.addButton(trUtf8("Ναί"),
                    QMessageBox::ActionRole);
    QAbstractButton *rej = m.addButton(trUtf8("Όχι"), QMessageBox::ActionRole);

    m.move(100, 100);
    QFont serifFont("Times", 18, QFont::Bold);
    m.setFont(serifFont);
    m.setDefaultButton((QPushButton*)rej);

    m.exec();
    if (m.clickedButton() == rej)
        return;

    if (m.clickedButton() == acc)
    {
        QSqlQuery query(db1);
        //qDebug()<<"TID"<<tk_id;
        query.exec("delete from tasks where id="+tk_id);
    }
    refresh_tasks();
    refresh_full_tasks();
    ui->pushDelete->setEnabled(FALSE);
    }
}
Exemplo n.º 9
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    this->tracking_status=FALSE;

    QIcon* icon =new QIcon((QString)APATH+"clock.png");
    ui->pushHour->setEnabled(FALSE);
    ui->pushHour->setIcon(*icon);
    ui->pushHour->setIconSize(QSize( ui->pushHour->size().width()-5,ui->pushHour->size().height()-5 ));
    QIcon* icon1 =new QIcon((QString)APATH+"add.png");
    ui->pushAddEarlier->setIcon(*icon1);
    ui->pushAddEarlier->setIconSize(QSize( ui->pushAddEarlier->size().width()-5,ui->pushAddEarlier->size().height()-5 ));
    QIcon* icon3 =new QIcon((QString)APATH+"delete.png");
    ui->pushDelete->setIcon(*icon3);
    ui->pushDelete->setIconSize(QSize( ui->pushDelete->size().width()-5,ui->pushDelete->size().height()-5 ));
    ui->pushDelete->setFocusPolicy(Qt::NoFocus);
    ui->pushAddEarlier->setFocusPolicy(Qt::NoFocus);
    ui->pushDelete->setEnabled(FALSE);
    QIcon* icon2 =new QIcon((QString)APATH+"hourglass.png");
    this->setWindowIcon(*icon2);
    db1=QSqlDatabase::addDatabase("QMYSQL","hourglass");
    db1.setDatabaseName("hourglass");
    db1.setHostName(g_HOST);
    db1.setUserName(g_USER);
    db1.setPassword(g_PASS);
    db1=QSqlDatabase::database("hourglass");
   // QPluginLoader *thePlugin = new QPluginLoader("/home/jim/qt/qt-4.6.3/plugins/sqldrivers/libqsqlmysql.so");
    //qDebug() << thePlugin->load();
    //qDebug() << thePlugin->isLoaded();
    //qDebug() << thePlugin->errorString();

    if (!db1.open())
    {
        qDebug()<<"Απέτυχε η σύνδεση με τη βάση";
        exit(0);
    }
    db2=QSqlDatabase::addDatabase("QMYSQL","asterisk");
    db2.setDatabaseName("asterisk");
    db2.setHostName(g_ASTERISK_SERVER);
    db2.setUserName(g_AST_MYSQL_USER);
    db2.setPassword(g_AST_MYSQL_PASS);
    db2=QSqlDatabase::database("asterisk");
    if (!db2.open())
    {
        qDebug()<<"Απέτυχε η σύνδεση με τη βάση";
        //exit(0);
    }
    this->customer_model=new QSqlQueryModel();
    this->project_model=new QSqlQueryModel();
    this->places_model=new QSqlQueryModel();
    this->tasks_model=new QSqlQueryModel();
    this->tasks_full_model=new QSqlQueryModel();
    this->daily_calls_model=new QSqlQueryModel();
    this->full_calls_model=new QSqlQueryModel();
    refresh_customers();
    refresh_tasks();
    refresh_full_tasks();
    refresh_daily_calls();
    refresh_full_calls();
    this->timer=new QTimer;
    this->timer_asterisk=new QTimer;
    timer_asterisk->start(60000);
    QStringList sl;
    ui->comboGraph->insertItem(0,trUtf8("ΕΒΔΟΜΑΔΑ"));
    ui->comboGraph->insertItem(1,trUtf8("ΕΤΟΣ"));
    ui->comboGraph->insertItem(2,trUtf8("ΔΙΑΧΡΟΝΙΚΟ"));
    /*
    QDate simera;
    simera=QDate::currentDate();
    int dayno=simera.dayOfWeek();

    QList <int> minut;
    for (int i=0;i<dayno;++i)
    {
        QSqlQuery query(db1);
        query.exec("select sum(TIMESTAMPDIFF(MINUTE,t.start_time,t.end_time)) from tasks t where date(start_time)='"+simera.addDays(-i).toString("yy/M/d")+"'");
        query.next();
        minut.prepend(query.value(0).toInt());
        qDebug()<<"MINUT:"<<minut;
    }


    WeekGraph *drb=new WeekGraph(this);
    drb->set_list(minut);
    drb->setFixedWidth(921);
    drb->setFixedHeight(181);
    drb->repaint();
    */
    drb=new WeekGraph(this);
    drb->setGeometry(180,10,611,151);
    //drb->setFixedWidth(621);
    //drb->setFixedHeight(161);

    connect(timer_asterisk,SIGNAL(timeout()),this,SLOT(refresh_calls()));
    connect(timer, SIGNAL(timeout()),this, SLOT(refresh_time()));
    connect(ui->action,SIGNAL(triggered()),this,SLOT(new_customer()));
    connect(ui->tableCustomers,SIGNAL(clicked(QModelIndex)),this,SLOT(customer_selection_changed()));
    connect(ui->tableCustomers,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_customer()));
    connect(ui->pushHour,SIGNAL(released()),this,SLOT(tracking_pressed()));
    connect(ui->textEdit,SIGNAL(textChanged()),this,SLOT(remove_invalid_chars()));
    connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task()));
    connect(ui->tableView_2,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task_full()));
    connect(ui->pushAddEarlier,SIGNAL(released()),this,SLOT(add_earlier_task()));
    connect(ui->actionMigration,SIGNAL(triggered()),this,SLOT(do_migration()));
    connect(ui->action_2,SIGNAL(triggered()),this,SLOT(invoicing()));
    connect(ui->actionEmail,SIGNAL(triggered()),this,SLOT(email_tasks()));
    connect(ui->comboGraph,SIGNAL(currentIndexChanged(int)),this,SLOT(change_graph(int)));
    connect(ui->actionProjects,SIGNAL(triggered()),this,SLOT(projects()));
    connect(ui->actionReview,SIGNAL(triggered()),this,SLOT(invoice_review()));
    connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(table_clicked()));
    connect(ui->tableView_2,SIGNAL(clicked(QModelIndex)),this,SLOT(table2_clicked()));
    connect(ui->pushDelete,SIGNAL(released()),this,SLOT(delete_clicked()));
    connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tab_changed(int)));

    ui->comboGraph->setCurrentIndex(-1);
    ui->comboGraph->setCurrentIndex(0);
    ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableTodayCalls->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableAllCalls->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->tableCustomers->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->tableView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu(const QPoint&)));
    connect(ui->tableView_2->horizontalHeader(),SIGNAL(sectionClicked(int)),this,SLOT(sortbycolumn(int)));
    connect(ui->tableCustomers,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(dial_customer(const QPoint&)));
    connect(ui->tableTodayCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_daily_calls(QPoint)));
    connect(ui->tableAllCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_full_calls(QPoint)));

    Asterisk_CallerID_Monitor *ast_monitor=new Asterisk_CallerID_Monitor(this);
    connect (ast_monitor,SIGNAL(incoming_call(QString)),this,SLOT(incoming_call(QString)));
    ast_monitor->start_monitor();

}
Exemplo n.º 10
0
void MainWindow::tracking_pressed()
{
    QSqlQuery query(db1);
    if(tracking_status==FALSE)
    {
        ui->comboplace->setEnabled(FALSE);
        ui->comboproject->setEnabled(FALSE);
        ui->tableCustomers->setEnabled(FALSE);
        ui->tableView->setEnabled(FALSE);
        ui->tableView_2->setEnabled(FALSE);
        QIcon* icon =new QIcon((QString)APATH+"clock_1.png");
        ui->pushHour->setIcon(*icon);
        ui->pushHour->setIconSize(QSize( ui->pushHour->size().width()-5,ui->pushHour->size().height()-5 ));
        ui->labelCustTime->setText(ui->label_customer->text());
        ui->labelTime->setText("00:00:00");
        QString placeid,projectid,price;
        if (ui->comboplace->currentIndex()!=-1)
            placeid=places_model->data(places_model->index(ui->comboplace->currentIndex(),1)).toString();
        else
            placeid="NULL";
        if (ui->comboproject->currentIndex()!=-1)
            projectid=project_model->data(project_model->index(ui->comboproject->currentIndex(),0)).toString();
        else
            projectid="NULL";
        tracking_status=TRUE;
        query.exec("select amount from debit_categories where cusid="+cusid+" and placeid="+placeid);
        if( query.next())
            price=query.value(0).toString();
        else
            price="0";
        query.exec("insert into tasks (cusid,placeid,projectid,start_time,price,comment) values ("+cusid+","+placeid+","+projectid+",NOW(),"+price+",'"+ui->textEdit->toPlainText()+"')");
        query.exec("select max(id) from tasks");
        query.next();
        current_task_id=query.value(0).toString();
        timer->start(1000);
        refresh_tasks();
        refresh_full_tasks();
        return;
    }

    if(tracking_status==TRUE)
    {
        tracking_status=FALSE;
        query.exec("update tasks set end_time=now() where id="+current_task_id);
        query.exec("update tasks set comment='"+ui->textEdit->toPlainText()+"' where id="+current_task_id);
        QIcon* icon =new QIcon((QString)APATH+"clock.png");
        ui->pushHour->setIcon(*icon);
        ui->pushHour->setIconSize(QSize( ui->pushHour->size().width()-5,ui->pushHour->size().height()-5 ));
        current_task_id="0";
        refresh_tasks();
        refresh_full_tasks();
        ui->comboGraph->setCurrentIndex(-1);
        ui->comboGraph->setCurrentIndex(0);

        timer->stop();
        ui->labelCustTime->setText("");
        ui->labelTime->setText("");
        ui->comboplace->setEnabled(TRUE);
        ui->comboproject->setEnabled(TRUE);
        ui->tableCustomers->setEnabled(TRUE);
        ui->tableView->setEnabled(TRUE);
        ui->tableView_2->setEnabled(TRUE);
        ui->textEdit->setPlainText("");
        return;
    }


}