Ejemplo n.º 1
0
void CarBlock::on_btnIsVisible_clicked()
{
    this->setEnabled(false);
    qApp->processEvents();
    static bool isVisible = isCarVisible;
    if(!isAddBlock) {
        if(Database::isOpen()) {
            isVisible = !isVisible;
            setVisibleButton(isVisible);
            QSqlQuery qry;
            qry.prepare("UPDATE car SET IsVisible=:_IsVisible,Status=:_Status WHERE idCar=:_id");
            qry.bindValue(":_id", idCar);
            qry.bindValue(":_IsVisible", isVisible);
            qry.bindValue(":_Status", !isVisible);
            if(!qry.exec())
                QMessageBox::warning(this,tr("Uwaga!"),"Aktualizacja nie powidoła się.\nERROR: "+qry.lastError().text()+"");
            else
                emit carDeleted(true); // only for update
        }
        else {
            QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
            emit changeStatusBar("Nie można połączyć z bazą danych");
        }
    }
    else {
        isVisible = !isVisible;
        setVisibleButton(isVisible);
    }
    this->setEnabled(true);
    qApp->processEvents();
}
Ejemplo n.º 2
0
bool ReportManager::generateReports(QListViewItem *lvi)
{
    bool errors = 0;

    changeStatusBar(i18n("Generating report: '%1'")
                            .arg(lvi->text(0)));

    if (!(errors = !generateReport(lvi)))
    {
        for (QListViewItem *lvi2 = lvi->firstChild(); lvi2; lvi2 = lvi2->nextSibling())
        {
            errors += generateReports(lvi2);
        }
    }

    changeStatusBar(i18n("The reports have been generated"));

    return errors;
}
Ejemplo n.º 3
0
void BackScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
    QStringList strList;
    QPoint newPoint = ic->getCooxWithPos(event->scenePos());
    if (!ic->isPointAvailable(newPoint)) {
        emit changeStatusBar(strList);
        newPoint = ic->outPoint();
        restoreOldPoint(oldPoint);
        if (oldPoint != newPoint) {
            oldPoint = newPoint;
        }
        return;
    }
    if (oldPoint == newPoint) {
        return;
    }
    restoreOldPoint(oldPoint);

    if (newPoint == ic->outPoint()) {
        ic->setElementRestorePen(oldPoint);
    }

    ic->setElementBoldPen(newPoint, 5);
    oldPoint = newPoint;

    GameMapElement* gmeT = ic->getMapElementByPoint(newPoint);

    if (HeroItem* hero = ic->getHeroByPoint(oldPoint)) {
        QString strHero = tr("hero: ") + hero->heroName();
        strList.append(strHero);
        emit heroMovedIn(hero);
    } else {
        QString strGme = tr("area: ") + gmeT->getElementName();
        strList.append(strGme);
        emit mapElementMovedIn(oldPoint);
    }
    QString coordinate = tr("coordinates: ") +
            QString::number(gmeT->point().x()) + tr(", ") +
            QString::number(gmeT->point().y());
    strList.append(coordinate);
    emit changeStatusBar(strList);
}
Ejemplo n.º 4
0
void CarBlock::on_btnOil_clicked()
{
    emit inProgress();
    if(Database::isOpen()) {
        oilDialog = new OilDialog(idCar);
        if(oilDialog->exec()== OilDialog::Rejected)
            delete oilDialog;
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
        emit changeStatusBar("Nie można połączyć z bazą danych");
    }
    emit progressFinished();
}
Ejemplo n.º 5
0
void CarBlock::on_btnViewRepairs_clicked()
{
    emit inProgress();
    if(Database::isOpen()) {
        serviceBlock = new ServiceBlock(idCar);
        if(serviceBlock->exec()== ServiceBlock::Rejected)
            delete serviceBlock;
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
        emit changeStatusBar("Nie można połączyć z bazą danych");
    }
    emit progressFinished();
}
Ejemplo n.º 6
0
void CarBlock::updateImagePath()
{
    if(Database::isOpen()) {
        QSqlQuery qry;
        qry.prepare("UPDATE car SET PhotoPath=:_PhotoPath WHERE idCar=:_id");
        qry.bindValue(":_id", idCar);
        qry.bindValue(":_PhotoPath", carPhotoPath);
        if(!qry.exec())
            QMessageBox::warning(this,tr("Uwaga!"),"Aktualizacja nie powidoła się.\nERROR: "+qry.lastError().text()+"");
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
        emit changeStatusBar("Nie można połączyć z bazą danych");
    }
}
Ejemplo n.º 7
0
void DBConfigDialog::on_deleteButton_clicked()
{
    if(currentAddress.isEmpty()){
        QMessageBox::information(this,tr("Informacja"),tr("Nie połączono z bazą danych."));
        return;
    }

    if(ui->rbRemoteDB->isChecked() && currentAddress=="127.0.0.1"){
        QMessageBox::information(this,tr("Informacja"),tr("Aby usunąć zdalną bazę danych proszę sie przelogować."));
        return;
    }

    else if (ui->rbLocalDB->isChecked() && currentAddress!="127.0.0.1"){
        QMessageBox::information(this,tr("Informacja"),tr("Aby usunąć lokalną bazę danych proszę sie przelogować."));
        return;
    }

    if(showMsgBeforeDelete()) {
        setGrayOut(true);

        QSqlQuery qry;
        qry.prepare("DROP DATABASE sigmacars");
        if(!qry.exec())
            QMessageBox::warning(this,tr("Uwaga!"),"Usuwanie nie powiodło się.\nERROR: "+qry.lastError().text()+"");
        else {
            QMessageBox::information(this,tr("Informacja"),tr("Usunięto bazę danych!"));
            QFile initFile1( QDir::currentPath()+"/init.txt" );
            initFile1.remove();
            QFile initFile2( QDir::currentPath()+"/init.txt" );
            if (!initFile2.open(QIODevice::WriteOnly))
                QMessageBox::critical(this,tr("Błąd!"), tr("Nie można otworzyć pliku z kofiguracją bazy danych."));

            currentAddress.clear();
            user.clear();
            password.clear();
            MainWindow::isDatabase = false;
            ui->leUser->clear();
            ui->lePassword->clear();
            ui->leAddress->clear();
            ui->lePort->clear();
            emit changeStatusBar("Nie można połączyć z bazą danych");
            emit connectedToDB(false);
        }

        setGrayOut(false);
    }
}
Ejemplo n.º 8
0
void CarBlock::on_btnAddInspection_clicked()
{
    emit inProgress();

    if(Database::isOpen()) {
        QSqlQuery qry;
        qry.prepare("UPDATE car SET InspectionDate=:_inspectionDate WHERE idCar=:_id");
        qry.bindValue(":_id", idCar);
        qry.bindValue(":_inspectionDate", ui->dateEditInspection->date());
        if(!qry.exec())
            QMessageBox::warning(this,tr("Uwaga!"),"Aktualizacja nie powidoła się.\nERROR: "+qry.lastError().text()+"");
        else
            QMessageBox::information(this,tr("Informacja"),tr("Zaktualizowano!"));
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
        emit changeStatusBar("Nie można połączyć z bazą danych");
    }

    emit progressFinished();
}
Ejemplo n.º 9
0
bool
ReportManager::showReport(QListViewItem* lvi, bool& showReportTab)
{
    ManagedReportInfo* mr = 0;
    showReportTab = true;
    if (!lvi)
    {
        /* If the lvi is null then we try to show the current report or the
         * first interactive report. */
        if (browser->currentItem())
            lvi = browser->currentItem();
        else if (qtReports->firstChild())
            lvi = (qtReports->firstChild());
    }
    for (std::list<ManagedReportInfo*>::const_iterator mri = reports.begin();
         mri != reports.end(); ++mri)
        if ((*mri)->getBrowserEntry() == lvi)
            mr = *mri;

    if (!mr)
    {
        /* In case there is no corresponding list view entry we show the
         * summary report. The summary report has no report definition, so it
         * can be identified by a 0 pointer. */
        for (std::list<ManagedReportInfo*>::const_iterator
             mri = reports.begin(); mri != reports.end(); ++mri)
            if ((*mri)->getProjectReport() == 0)
            {
                mr = *mri;
                break;
            }
    }

    TjUIReportBase* tjr = mr->getReport();
    Report *rep = mr->getProjectReport();
    const char * type = rep ? rep->getType() : "";
    bool result = true;
    if (tjr == 0)
    {
        if (rep == 0)
            tjr = new TjSummaryReport(reportStack, this, project);
        else if (strcmp(type, "QtTaskReport") == 0)
            tjr = new TjTaskReport(reportStack, this, rep);
        else if (strcmp(type, "QtResourceReport") == 0)
            tjr = new TjResourceReport(reportStack, this, rep);
        else if (strncmp(type, "CSV", 3) == 0)
        {
            if (!rep->generate())
                result = false;
            // show the CSV file in preferred CSV handler
            QString baseDir;
            if (rep->getFileName()[0].latin1() == '/')
                baseDir = "/";
            else
                baseDir = rep->getDefinitionFile();
            KURL reportUrl =
                KURL::fromPathOrURL(baseDir);
            reportUrl.setFileName(rep->getFileName());
            changeStatusBar(i18n("Displaying CSV report: '%1'")
                            .arg(rep->getFileName()));
            KRun::runURL(reportUrl, "text/x-csv");
        }
        else if (strncmp(type, "SVG", 3) == 0)
        {
            if (!rep->generate())
                result = false;
            // show the SVG file in preferred SVG handler
            KURL reportUrl =
                KURL::fromPathOrURL(rep->getDefinitionFile());
            reportUrl.setFileName(rep->getFileName());

            changeStatusBar(i18n("Displaying SVG report: '%1'")
                            .arg(rep->getFileName()));
            KRun::runURL(reportUrl, "image/svg+xml");
        }
        else if (strncmp(type, "HTML", 4) == 0)
            tjr = new TjHTMLReport(reportStack, this, rep);
        else if (strncmp(type, "ICal", 4) == 0)
        {
            if (!rep->generate())
                result = false;
            else
            {
                // show the TODO list in Korganizer
                KURL reportUrl =
                    KURL::fromPathOrURL(rep->getDefinitionFile());
                reportUrl.setFileName(rep->getFileName());

                changeStatusBar(i18n("Displaying iCalendar: '%1'")
                                .arg(rep->getFileName()));
                KRun::runURL(reportUrl, "text/calendar");
            }
        }
        else if (strncmp(type, "Export", 6) == 0)
        {
            // Generate the report file
            if (!rep->generate())
                result = false;
            else
            {
                // Get the full file name as URL and show it in the editor
                KURL reportUrl =
                    KURL::fromPathOrURL(rep->getFullFileName());
                if (reportUrl.url().right(4) == ".tjp")
                {
                    changeStatusBar(i18n("Starting new TaskJuggler for '%1'")
                                    .arg(rep->getFileName()));
                    KRun::runURL(reportUrl, "application/x-tjp");
                }
                else
                {
                    emit signalEditFile(reportUrl);
                    showReportTab = false;
                }
            }
        }
        else if (strncmp(type, "XMLReport", 9) == 0)
        {
            bool result = rep->generate();
            if (result)
            {
                KMessageBox::information
                    (mainWindow, i18n("The report '%1' has been generated.")
                     .arg(rep->getFileName()),
                     QString::null, "XMLReportGeneratedInfo");
                changeStatusBar(i18n("The report '%1' has been generated")
                    .arg(rep->getFileName()));
            }
            else
                changeStatusBar(i18n("Could not generated report '%1'")
                    .arg(rep->getFileName()));
        }
        else
        {
            kdDebug() << "Report type " << type << " not yet supported" << endl;
            result = false;
        }

        if (!tjr)
        {
            /* A report with no widget that can be embedded in the report view
             * has been selected. We fall back to show the summary report and
             * unselect the selected browser item. */
            if (browser->currentItem())
                browser->setSelected(browser->currentItem(), false);
            tjr = new TjSummaryReport(reportStack, this, project);
        }

        connect(tjr, SIGNAL(signalChangeStatusBar(const QString&)),
                this, SLOT(changeStatusBar(const QString&)));
        connect(tjr, SIGNAL(signalEditCoreAttributes(CoreAttributes*)),
                this, SLOT(editCoreAttributes(CoreAttributes*)));

        if (!tjr->generateReport())
        {
            delete tjr;
            if (browser->currentItem())
                browser->setSelected(browser->currentItem(), false);
            return false;
        }

        reportStack->addWidget(tjr);
        mr->setReport(tjr);
    }

    // in older versions of KDE, this produces a (seemingly harmless) warning
    //    ASSERT: "id < (int)d->m_list.count()" in ./kdeui/kactionclasses.cpp (433)
    reportStack->raiseWidget(tjr);

    return result;
}
Ejemplo n.º 10
0
void DBConfigDialog::on_runButton_clicked()
{
    bool isLocal;
    bool isDbExist = false;

    if(ui->cbImport->isChecked() && (ui->lePath->text().isEmpty() || !ui->lePath->text().contains(".sql"))) {
        QMessageBox::information(this,tr("Informacja"), tr("Nie poprawna scieżka do importu bazy danych."));
        return;
    }


    setGrayOut(true);

    if(ui->rbLocalDB->isChecked()) {
        Database::purgeDatabase();
        if(createMode){
            if(ui->cbImport->isChecked()){
                if(createDatabase("\"" + QDir::currentPath() + "\\\"" + "mysqlRun -h127.0.0.1 -P3306 -uroot -pPASSWORD -f"+importPath+"")) {
                    QMessageBox::information(this,tr("Informacja"), tr("Baza danych już istnieje."));
                    isDbExist = true;
                }
            }
            else {
                if(createDatabase("\"" + QDir::currentPath() + "\\\"" + "mysqlRun -h127.0.0.1 -P3306 -uroot -pPASSWORD -dsigmacars")) {
                    QMessageBox::information(this,tr("Informacja"), tr("Baza danych już istnieje."));
                    isDbExist = true;
                }
            }
        }
        Database::setParameters("127.0.0.1", 3306,"sigmacars", "root","PASSWORD");
        isLocal = true;
    }

    else if (ui->rbRemoteDB->isChecked()) {

        if(dataIsEmpty()){
            setGrayOut(false);
            return;
        }

        Database::purgeDatabase();
        if(createMode){
            if(ui->cbImport->isChecked()){
                if(createDatabase("\"" + QDir::currentPath() + "\\\"" + "mysqlRun -h" + ui->leAddress->text() + " -P" + ui->lePort->text() + " -u" + ui->leUser->text() + " -p" + ui->lePassword->text() + " -f"+importPath)) {
                    QMessageBox::information(this,tr("Informacja"), tr("Baza danych już istnieje."));
                    isDbExist = true;
                }
            }
            else {
                if(createDatabase("\"" + QDir::currentPath() + "\\\"" + "mysqlRun -h" + ui->leAddress->text() + " -P" + ui->lePort->text() + " -u" + ui->leUser->text() + " -p" + ui->lePassword->text() + " -dsigmacars")) {
                    QMessageBox::information(this,tr("Informacja"), tr("Baza danych już istnieje."));
                    isDbExist = true;
                }
            }
        }
        Database::setParameters(ui->leAddress->text(), ui->lePort->text().toInt(),"sigmacars", ui->leUser->text(),ui->lePassword->text());
        isLocal = false;
    }

    if(Database::connectToDatabase()) {
        if(!createMode)QMessageBox::information(this,tr("Informacja"), tr("Pomyślnie połączono z bazą danych."));
        else if(isDbExist)
            QMessageBox::information(this,tr("Informacja"), tr("Pomyślnie połączono z bazą danych."));
        else
            QMessageBox::information(this,tr("Informacja"), tr("Pomyślnie dodano bazę danych."));

        if(isLocal) {
            if(!writeToFile("127.0.0.1", 3306, "sigmacars", "root","PASSWORD"))
                return;
            user="******";
            password="******";
            currentAddress="127.0.0.1";
        }
        else {
            if(!writeToFile(ui->leAddress->text(), ui->lePort->text().toInt(),
                    "sigmacars", ui->leUser->text(),ui->lePassword->text()))
                return;
            user=ui->leUser->text();
            password=ui->lePassword->text();
            currentAddress=ui->leAddress->text();
        }

        setGrayOut(false);
        MainWindow::isDatabase = true;
        Database::isLocal = isLocal;
        emit connectedToDB(false);
        this->accept();
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Nie połączono z bazą danych!"));
        setGrayOut(false);
        MainWindow::isDatabase = false;
        emit changeStatusBar("Nie można połączyć z bazą danych");
        emit connectedToDB(false);
        return;
    }
}
Ejemplo n.º 11
0
void CarBlock::on_btnRemove_clicked()
{
    emit inProgress();

    if(Database::isOpen()) {
        if(!isAddBlock) {

            if(!showMsgBeforeDelete()){
                    emit progressFinished();
                    return;
            }

            QSqlQuery qry;
            qry.prepare("DELETE FROM car WHERE idCar=:_id");
            qry.bindValue(":_id", idCar);
            if(!qry.exec())
                QMessageBox::warning(this,tr("Uwaga!"),"Usuwanie nie powiodło się.\nERROR: "+qry.lastError().text()+"");
            else {
                QMessageBox::information(this,tr("Informacja"),tr("Usunięto samochód!"));
                emit carDeleted(true);
            }
        }

        else {
            QSqlQuery qry;
            qry.prepare("INSERT INTO car(Brand,Model,LicensePlate,InspectionDate,"
                                        "InsuranceDate,Mileage,Status,PhotoPath,IsVisible)"
                         "VALUES(:_Brand,:_Model,:_LicensePlate,:_InspectionDate,"
                         ":_InsuranceDate,:_Mileage,:_Status,:_PhotoPath,:_IsVisible)");
            if(ui->lblCarName->text().contains(" ")) {
                qry.bindValue(":_Brand", ui->lblCarName->text().split(" ").at(0));
                qry.bindValue(":_Model", ui->lblCarName->text().split(" ").at(1));
            }
            else {
                qry.bindValue(":_Brand", ui->lblCarName->text());
                qry.bindValue(":_Model", ui->lblCarName->text());
            }

            qry.bindValue(":_LicensePlate", ui->lblLicensePlate->text());
            qry.bindValue(":_InspectionDate",ui->dateEditInspection->date());
            qry.bindValue(":_InsuranceDate",ui->dateEditInsurance->date());
            if(getCarVisible())qry.bindValue(":_Status",0);
            else qry.bindValue(":_Status",1);
            qry.bindValue(":_Mileage", ui->lblMileage->text());
            if(!carPhotoPath.isEmpty())qry.bindValue(":_PhotoPath",carPhotoPath);
            else qry.bindValue(":_PhotoPath", QString(":/images/images/car.png"));
            qry.bindValue(":_IsVisible", getCarVisible());
            if(!qry.exec())
                QMessageBox::warning(this,tr("Uwaga!"),"Dodawanie nie powiodło się.\nERROR "+qry.lastError().text()+"");
            else {
                QMessageBox::information(this,tr("Informacja"),tr("Dodano samochód!"));
                emit carAdded(false);
            }
        }
    }
    else {
        QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!"));
        emit changeStatusBar("Nie można połączyć z bazą danych");
    }

    emit progressFinished();
}