Logo Search packages:      
Sourcecode: qlandkarte version File versions  Download package

void GUICallback ( int  progress,
int *  ok,
int *  cancel,
const char *  title,
const char *  msg,
void *  self 
) [friend]

Parameters:
progress the progress as integer from 0..100, if -1 no progress bar needed.
ok if this pointer is 0 no ok button needed, if non zero set to 1 if ok button pressed
cancel if this pointer is 0 no cancel button needed, if non zero set to 1 if cancel button pressed
title dialog title as C string
msg dialog message C string to display
self void pointer as provided while registering the callback

Definition at line 52 of file CCentralResources.cpp.

Referenced by device().

{
    CCentralResources * parent = static_cast<CCentralResources *>(self);
    CCentralResources::dlgdata_t& dd = parent->dlgData;

    if(progress != -1) {
        quint32 togo, hour, min, sec;
        QString message;

        if(dd.dlgProgress == 0) {
            dd.canceled     = false;
            dd.dlgProgress  = new QProgressDialog(QString(title),0,0,100,&parent->main,
                Qt::WindowStaysOnTopHint);
            dd.timeProgress.start();
            if(cancel) {
                QPushButton * butCancel = new QPushButton(QObject::tr("Cancel"),dd.dlgProgress);
                parent->connect(butCancel, SIGNAL(clicked()), parent, SLOT(slotCancel()));
                dd.dlgProgress->setCancelButton(butCancel);
            }
        }

        if(title) dd.dlgProgress->setWindowTitle(QString(title));

        togo = (quint32)((100.0 * (double)dd.timeProgress.elapsed() / (double)progress) + 0.5);
        togo = (quint32)((double)(togo - dd.timeProgress.elapsed()) / 1000.0 + 0.5);

        hour = (togo / 3600);
        min  = (togo - hour * 3600) / 60;
        sec  = (togo - hour * 3600 - min * 60);

        message.sprintf(QObject::tr("\n\nEstimated finish: %02i:%02i:%02i [hh:mm:ss]").toUtf8(),hour,min,sec);

        dd.dlgProgress->setLabelText(QString(msg) + message);
        dd.dlgProgress->setValue(progress);

        if(progress == 100 && dd.dlgProgress) {
            delete dd.dlgProgress;
            dd.dlgProgress = 0;
        }

        if(cancel) {
            *cancel = dd.canceled;
        }

        qApp->processEvents();

    }
    else {
        if(ok && cancel) {
            QMessageBox::StandardButtons res = QMessageBox::question(&parent->main,QString(title),QString(msg),QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Cancel);
            *ok     = res == QMessageBox::Ok;
            *cancel = res == QMessageBox::Cancel;
        }
        else if(ok && !cancel) {
            QMessageBox::question(&parent->main,QString(title),QString(msg),QMessageBox::Ok,QMessageBox::Ok);
            *ok     = true;
        }
        else if(!ok && cancel) {
            QMessageBox::question(&parent->main,QString(title),QString(msg),QMessageBox::Cancel,QMessageBox::Cancel);
            *cancel     = true;
        }
        else if(!ok && !cancel) {
            //kiozen - that doesn't work nicely
            //             QMessageBox * dlg = new QMessageBox(&parent->main);
            //             dlg->setWindowTitle(QString(title));
            //             dlg->setText(QString(msg));
            //             dlg->setStandardButtons(QMessageBox::NoButton);
            //             dlg->setIcon(QMessageBox::Information);
            //             dlg->show();
            //             qApp->processEvents(QEventLoop::AllEvents, 1000);
            //             sleep(3); // sleep for 3 seconds
            //             delete dlg;
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index