void GuiActivityInventorySheet::on_InsertInTTSButton_clicked()
{

    Activity at = select<Activity>(*(mpDatabase), Activity::Id == this->mRow).one();
    try {
        mpTts = new TodoTodaySheet(select<TodoTodaySheet>(*(mpDatabase), TodoTodaySheet::Id == 1).one());
    } catch (NotFound e) {
        mpTts = new TodoTodaySheet(*(mpDatabase));
        mpTts->update();
    }

    vector<Activity> currentTDTSActivities = ActivityInTTS::get<Activity>(*(mpDatabase),Expr(),
            ActivityInTTS::TodoTodaySheet==mpTts->id).all();
    int check = 0;
    for (vector<Activity>::iterator i = currentTDTSActivities.begin(); i != currentTDTSActivities.end(); i++) {
        if ((*i).id == this->mRow) check = 1;
    }
    if (check == 0 ) {
        ActivityInventorySheet &cAis = *(mpAis);
        TodoTodaySheet &cTts = *(mpTts);
        cTts.ScheduleActivity(*(mpDatabase), at, cAis, cTts);
        mpDatabase->commit();
        emit DatabaseUpdated();
    } else {
        QMessageBox msgBox;
        msgBox.setText("Activity already scheduled in TTS");
        msgBox.exec();
    }
    ui->DeleteActivityButton->setEnabled(false);
    ui->ModifyActivityButton->setEnabled(false);
    ui->InsertInTTSButton->setEnabled(false);

}
Beispiel #2
0
void SlimServerInfo::refreshImageFromServer(void)
{
    DEBUGF("");
    db = new SlimDatabaseFetch();
    connect(db,SIGNAL(FinishedUpdatingDatabase()),
            this,SLOT(DatabaseUpdated()));

    db->Init(SlimServerAddr,cliPort,cli->GetCliUsername(),cli->GetCliPassword());
    db->start();    // init database fetching thread
}
GuiActivityInventorySheet::GuiActivityInventorySheet(QWidget *parent, PomotuxDatabase& database)
    : QMainWindow(parent), ui(new Ui::GuiActivityInventorySheet)
{
    mpDatabase = &database;
    wAbout = new AboutWindow(this);

    ui->setupUi(this);

    try {
        mpAis = new ActivityInventorySheet(select<ActivityInventorySheet>(*(mpDatabase), ActivityInventorySheet::Id == 1).one());
    } catch (NotFound e) {
        mpAis = new ActivityInventorySheet(*(mpDatabase));
        mpAis->update();
    }

    this->wTTS = new TodoTodaySheetGui(this,*(this->mpDatabase));
    this->wPreferences = new PreferencesDialog (this,*(this->mpDatabase));
    this->wModifyActivity = new ModifyAnActivity(this,*(this->mpDatabase),mRow);
    this->wInsertActivity = new InsertNewActivity(this,*(this->mpDatabase));

    // connection of signal required to refresh preferences
    connect(this->wPreferences,SIGNAL(DatabaseUpdated()),this->wTTS,SLOT(RefreshPreferences()));

    // connection of signals for refreshing tables
    connect(this->wTTS,SIGNAL(DatabaseUpdated()),this,SLOT(RefreshTable()));
    connect(this,SIGNAL(DatabaseUpdated()),this->wTTS,SLOT(RefreshTable()));
    connect(this,SIGNAL(DatabaseUpdated()),this,SLOT(RefreshTable()));
    connect(this->wInsertActivity,SIGNAL(DatabaseUpdated()),this,SLOT(RefreshTable()));
    connect(this->wTTS->getInsertActivity(),SIGNAL(DatabaseUpdated()),this,SLOT(RefreshTable()));
    connect(this->wModifyActivity,SIGNAL(DatabaseUpdated()),this,SLOT(RefreshTable()));
    connect(this->wModifyActivity,SIGNAL(DatabaseUpdated()),this->wTTS,SLOT(RefreshTable()));

    // connection of menu bar actions
    connect(this->ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
    connect(this->ui->actionPreferences,SIGNAL(triggered()),this,SLOT(Preferences()));
    connect(this->ui->actionAbout,SIGNAL(triggered()),this,SLOT(About()));

    emit DatabaseUpdated();
    this->RefreshTable();
    this->ui->ais->setColumnWidth(0, 0);
    this->ui->ais->setColumnWidth(1, 440);
}
Beispiel #4
0
void ModifyAnActivity::on_ButtonBox_accepted()
{
    try {
        Activity current = select<Activity>(*(mpDatabase), Activity::Id == *(this->mrSelectedActivity)).one();
        QString newDescription = this->m_ui->mADescriptionLineEdit->text();
        time_t deadline= mNow + (this->m_ui->mADeadlineSpinBox->text().toInt())*(86400);
        current.Modify(*(mpDatabase), current, (int)deadline , newDescription.toStdString());
        emit DatabaseUpdated();
        this->m_ui->mADescriptionLineEdit->setText("");
        this->m_ui->mADeadlineSpinBox->setValue(0);
        this->hide();
    } catch (Except e) {
        ostringstream errorMsg;
        errorMsg <<"liteSQL ERROR :"<< e;
        QMessageBox msgBox;
        msgBox.setText(errorMsg.str().c_str());
        msgBox.exec();
    } catch (PomotuxException e) {
        QMessageBox msgBox;
        msgBox.setText(e.getMessage());
        msgBox.exec();
    }
}
void GuiActivityInventorySheet::on_DeleteActivityButton_clicked()
{
    if(!this->wTTS->IsPomodoroRunning()) {
        try {
            Activity at = select<Activity>(*(mpDatabase), Activity::Id == this->mRow).one();
            mpTts = new TodoTodaySheet(select<TodoTodaySheet>(*(mpDatabase), TodoTodaySheet::Id == 1).one());
            ActivityInventorySheet &cAis = *(mpAis);
            TodoTodaySheet &cTts = *(mpTts);
            at.Delete(*(mpDatabase), at, cAis, cTts);
            emit DatabaseUpdated();
        } catch (NotFound e) {
            mpTts = new TodoTodaySheet(*(mpDatabase));
            mpTts->update();
        }
        ui->DeleteActivityButton->setEnabled(false);
        ui->ModifyActivityButton->setEnabled(false);
        ui->InsertInTTSButton->setEnabled(false);
    } else {
        QMessageBox msgBox;
        msgBox.setText("You have to wait until Pomodoro is finished.");
        msgBox.exec();
    }
}