PageRenderTime 68ms CodeModel.GetById 12ms app.highlight 50ms RepoModel.GetById 2ms app.codeStats 0ms

/vp_plugins/print_monitor/engine.cpp

http://cupsfilter.googlecode.com/
C++ | 641 lines | 531 code | 55 blank | 55 comment | 30 complexity | e610e3fe9d88092ca8902a14536bedf5 MD5 | raw file
  1#include "engine.h"
  2#include "mysocketclient.h"
  3#include "message.h"
  4
  5#include <QtCore/QDebug>
  6#include <QtCore/QFile>
  7#include <QtCore/QDir>
  8//#include <QtCore/QFileInfoList>
  9#include <QtCore/QProcess>
 10#include <QtCore/QMetaType>
 11#include <QtCore/QTimer>
 12#include <QtCore/QRegExp>
 13#include <QtCore/QStringList>
 14
 15#include <QtGui/QStandardItem>
 16#include <QtGui/QStringListModel>
 17#include <QtGui/QStandardItemModel>
 18#include <QtCore/QModelIndex>
 19#include <QtCore/QDataStream>
 20#include <QPair>
 21
 22Engine::Engine(QObject *parent,const QString &link,const QString &gk_bin)
 23        : QObject(parent)
 24        , m_DC_model(0)
 25        , m_Prn_model(0)
 26        , m_Tmpl_model(0)
 27        , m_Mandats_model(0)
 28        , m_Stamp_model(0)
 29        , m_LocalClient(0)
 30        , stopLaunch(false)
 31        , currentUserName(QString())
 32        , currentUserMandat(QString())
 33        , link_name(QString())
 34        , gatekeeper_bin(QString())
 35{
 36    qRegisterMetaType<VPrn::MessageType>("MessageType");
 37    link_name      = link;
 38    gatekeeper_bin = gk_bin;    
 39}
 40
 41
 42Engine::~Engine()
 43{
 44    if (m_LocalClient){
 45        m_LocalClient->disconnectFromServer();
 46    }
 47}
 48
 49void Engine::prepareFileToPrint(const QString & file_name)
 50{
 51    // ?????? ? ????? ????????? ??????  ????????????? ps -> pdf
 52    Message msg(this);
 53    msg.setType(VPrn::Que_Convert2Pdf);
 54    msg.setMessageData( file_name.toUtf8() ); // ?????????? ? QByteArray
 55    sendMessage2LocalSrv(msg);
 56}
 57
 58void Engine::needRestart()
 59{
 60    QString mb;
 61    QString cur_copy;
 62    QString total_copy;
 63    QModelIndex indx;
 64
 65    //??????? ?????? ?? ??????
 66    indx = m_DC_model->index(0,VPrn::cards_MB_NUMBER);
 67    mb   = m_DC_model->data(indx,Qt::DisplayRole).toString() ;
 68
 69    indx = m_DC_model->index(0,VPrn::cards_CURRENT_COPY);
 70    cur_copy = m_DC_model->data(indx,Qt::DisplayRole).toString();
 71
 72    indx = m_DC_model->index(0,VPrn::cards_COPY_COUNT);
 73    total_copy = m_DC_model->data(indx,Qt::DisplayRole).toString();
 74
 75    QString str = tr("%1;:;%2;:;%3;:;")
 76                  .arg(mb).arg(cur_copy).arg(total_copy);
 77
 78    indx = m_DC_model->index(0,VPrn::cards_SELECT_ALL_COPY);
 79    if (m_DC_model->data(indx,Qt::DisplayRole).toBool()){
 80        str.append("true");
 81    }else{
 82        str.append("false");
 83    }
 84
 85    //???????? ?????? ?????? ?? ?????????? ????????
 86    Message msg(this);
 87    msg.setType( VPrn::Que_UserDemands2Restart );
 88    msg.setMessageData( str.toUtf8() );
 89    sendMessage2LocalSrv( msg );
 90}
 91
 92//-------------------------------- PUBLIC SLOTS  -------------------------------
 93void Engine::setAuthData(const QString &login,const QString &mandat)
 94{
 95    currentUserName = login;
 96    currentUserMandat = mandat;
 97    emit ReciveUserName();
 98    emit ReciveUserMandat();
 99
100    // ?????? ? ????? ????????? ?????? ????????? ??????? ??????????? ???
101    Message msg(this);
102    msg.setType(VPrn::Que_SEC_LEVEL);
103    msg.setMessageData( currentUserMandat.toUtf8() ); // ?????????? ? QByteArray
104    sendMessage2LocalSrv(msg);
105}
106
107void Engine::launchAndConnect()
108{
109    if (!link_name.isEmpty() &&  QFile::exists(gatekeeper_bin)){
110        if (!m_LocalClient){
111
112            m_LocalClient = new mySocketClient();
113            connect (m_LocalClient, SIGNAL(checkPointChanged(MyCheckPoints)),
114                     this, SLOT(do_checkPointChanged(MyCheckPoints))
115                     );
116            connect (m_LocalClient, SIGNAL(messageReady( const Message &)),
117                     this, SLOT(parseMessage(const Message &))
118                     );
119        }
120        // ????????????? ?????????? ? ????????? ????????
121        m_LocalClient->connectToServer(link_name);
122
123    }else{
124        emit error(VPrn::ConfigError,
125                   QObject::trUtf8("?????? ? ????? ????????????. ????????? ?????????:\n"
126                                   " ?????? [SERVICE] ???????? link_name\n"
127                                   " ?????? [USED_DIR_FILE] ???????? gatekeeper_bin\n%1")
128                   .arg(QString(Q_FUNC_INFO))
129                   );
130    }
131}
132
133void Engine::authUserToPrinter()
134{
135    // ?????? ? ????? ????????? ?????? ??????????? ???????????? ?? ?????? ? ???????
136    Message msg(this);
137    msg.setType( VPrn::Que_AUTHOR_USER  );
138
139    // ?????????  ????? ??????? ?????? ???? ?? ????????? ???? ???????
140    msg.setMessageData( findPrinterInModel().toUtf8() ); // ?????????? ? QByteArray
141    sendMessage2LocalSrv(msg);
142}
143
144void Engine::checkMB()
145{
146    QString sql_query;
147    /**
148      * @brief ????????? sql ?????? ???????????:
149      * - ?????? ???????? (??,????? ???.) ?? ??????????????? ? ??
150      * - ?????? ???????? (??,????? ???.) ??????????????? ? ??, ?? ??????? ??? ????
151      */
152    Message msg(this);
153    msg.setType( VPrn::Que_IS_MB_EXIST  );
154    msg.setMessageData( sql_query.toUtf8() );
155    sendMessage2LocalSrv(msg);
156}
157
158void Engine::registerMB()
159{
160    QString sql_query;
161    /**
162      * @brief ????????? sql ?????? ?????????????? ???????? ? ?? ?????
163      * - ?????? ???????? (??,????? ???.) ?? ??????????????? ? ??
164      * - ?????? ???????? (??,????? ???.) ??????????????? ? ??, ?? ??????? ??? ????
165      */
166    Message msg(this);
167    msg.setType( VPrn::Que_RegisterDocInBase  );
168    msg.setMessageData( sql_query.toUtf8() );
169    sendMessage2LocalSrv(msg);
170}
171
172void Engine::do_select_mode(int mode)
173{
174    QByteArray field_data;
175    Message msg(this);
176
177    // ????????? ????? ?????? ?? ?????? ??? ???????? ?????????? ???????
178    field_data = getAllFieldData();
179    bool Ok =true;
180    {
181
182        switch (mode){
183        case VPrn::pre_FullMode:
184            msg.setType( VPrn::Que_CreateFormatedFullDoc );
185            break;
186        case VPrn::pre_PartMode:
187            msg.setType( VPrn::Que_CreateFormatedPartDoc );
188            break;
189        case VPrn::pre_ClearPrintMode:
190            msg.setType( VPrn::Que_CreateFormatedFullDocAndPrint );
191            break;
192        default:
193            emit error(VPrn::notDefainedMode,
194                       QObject::trUtf8("?????? ?? ???????????? ????? ?????????????/??????.\n%1")
195                       .arg(QString(Q_FUNC_INFO))
196                       );
197            Ok &= false;
198            break;
199        }
200    }
201    if (Ok){
202        msg.setMessageData( field_data );
203        sendMessage2LocalSrv(msg);
204    }
205}
206
207void Engine::do_printCurrentDoc()
208{
209    Message msg(this);
210    msg.setType( VPrn::Que_PrintCurrentFormatedDoc );
211    //msg.setMessageData ( findPrinterInModel().toUtf8() );
212    sendMessage2LocalSrv( msg );
213}
214
215void Engine::markCurrentDocBrack()
216{
217    Message msg(this);
218    msg.setType( VPrn::Ans_UserNeedMarkCopies );
219    msg.setMessageData ( QString("BRAK").toUtf8() );
220    sendMessage2LocalSrv( msg );
221
222}
223void Engine::markCurrentDocClear()
224{
225    Message msg(this);
226    msg.setType( VPrn::Ans_UserNeedMarkCopies );
227    msg.setMessageData ( QString("CLEAR").toUtf8() );
228    sendMessage2LocalSrv( msg );
229
230}
231
232//-------------------------------- PRIVATE SLOTS -------------------------------
233void Engine::do_checkPointChanged(MyCheckPoints r_cpoint)
234{
235    Message msg(this);
236    if (r_cpoint == VPrn::loc_Connected){
237        emit LocalSrvRegistr();
238
239        //?????? ???????????
240        msg.setType(VPrn::Que_Register);
241        //msg.setMessageData( clientName.toUtf8() ); // ?????????? ? QByteArray
242        sendMessage2LocalSrv(msg);
243    }
244    if (r_cpoint ==  VPrn::loc_ServerNotFound && !stopLaunch){
245        QProcess proc;
246        // ?????? ???????? ?????? ???????
247        if (proc.startDetached (gatekeeper_bin)){
248            // ??????? ????? 2
249            stopLaunch = true;
250        }else{
251            emit error(VPrn::appNotStarted,QString("%1\n%2").arg(proc.errorString()).arg(QString(Q_FUNC_INFO)) );
252        }
253        QTimer::singleShot(3000,this,SLOT(launchAndConnect()));
254    }
255}
256
257void Engine::parseMessage(const Message &r_msg)
258{
259    Message msg(this);
260    msg.clear();
261    QString str;
262
263    MessageType mType = r_msg.getType();
264    switch (mType){
265    case VPrn::Que_BeginPrintCopies:{	
266            str = QObject::trUtf8("?????? ?????? ?????????: ");
267            str.append(r_msg.getMessageData());
268
269            emit showInfoMsg(str);
270            qDebug() << "Recive msg: VPrn::Que_BeginPrintCopies";
271            // ????????? ??????
272            do_printCurrentDoc();
273        }
274        break;
275    case VPrn::Que_UserNeedFlipPages:{
276            qDebug() << "Recive msg: VPrn::Que_UserNeedFlipPages";
277            str = QObject::trUtf8("???????? ?????? ??????? ??????, ?????????? ??????????? ?????!");
278            emit showInfoMsg(str);
279            emit UserNeedFlipPages();
280        }
281        break;
282    case VPrn::Que_UserNeedCheckLastPage:{
283            qDebug() << "Recive msg: VPrn::Que_UserNeedCheckLastPage";
284            str = QObject::trUtf8("???????? ?????? ???????? ??????, ?????????? ????????? ????????? ???? ??? ?????? ????????!");
285            emit showInfoMsg(str);
286            emit UserNeedCheckLastPage();
287        }
288        break;
289    case VPrn::Que_UserNeedMarkCopies:{
290            str = QObject::trUtf8("???????? ??????, ?????????? ????????? ????????!");
291            emit showInfoMsg(str);
292            emit UserNeedMarkCopies( r_msg.getMessageData() );
293        }
294        break;
295    case VPrn::Ans_Register: {
296            // ?????? ??????????????? ???????? ?????????? ?? GateKeeper ?????????? ?????
297            client_uuid.clear();
298            client_uuid.append(r_msg.getMessageData());
299            if (m_DC_model){
300                m_DC_model->setItem(0,VPrn::cards_ID,
301                                    new QStandardItem(client_uuid)
302                                    );
303            }
304            emit LocalSrvRegistr();
305            // ?????? ? ?????????? ??????? ??? ????????? ????????? ??????:
306            // ?? ????? ? ?????? (??????????? ? ???? ?????????)
307            // ????? ? ?????? (???? auth ?????? ????????????, ???? ????? ? ???????)
308            // ???????? ????? (???? ??? ????????????,???? ????? ? ???????, ??? ???????
309            msg.setType(VPrn::Que_ServerStatus);
310            sendMessage2LocalSrv(msg);
311        }
312        break;
313    case VPrn::Ans_SrvStatusFullReady:
314        {
315            str.append(r_msg.getMessageData());
316            // ???????? ????? ???????, ? ??????? : ???;:;??????
317            QRegExp rx("(.+);:;(.+)");
318            //rx.setMinimal(true);
319            if(rx.indexIn(str) != -1){
320                currentUserName   = rx.cap(1);
321                currentUserMandat = rx.cap(2);
322                //?????? ??????? ??????????? ??? ???????
323                setAuthData(currentUserName,currentUserMandat );
324                afterConnectSteps();
325            }else{
326                emit error(VPrn::SocketError,
327                           QObject::trUtf8("?????? ??? ????????? ????? ? ??????? ??????? ????????????")
328                           .arg(QString(Q_FUNC_INFO))
329                           );
330            }
331        }
332        break;
333    case VPrn::Ans_SrvStatusNotReady:{
334            str.append(r_msg.getMessageData());
335            emit gk_notReady(QObject::trUtf8("GateKeeper ?? ????? ? ?????? ?? ??????? [%1]")
336                             .arg(str)
337                             );
338        }
339        break;
340    case VPrn::Ans_SrvStatusPartReady:{
341            str.append(r_msg.getMessageData());
342            emit needAuthUser(str);
343            afterConnectSteps();
344        }
345        break;
346    case VPrn::Ans_TemplateNotFound:{
347            str.append( r_msg.getMessageData() );
348            emit MergeDocWithTemplates( false, str);
349        }
350        break;
351    case VPrn::Ans_GiveMeTemplatesList:{
352            // ???????? ?????? ??????? ? ??????
353            saveTemplatesListToModel( r_msg.getMessageData() );
354        }
355        break;
356    case Ans_SourceDocNotFound:{
357            // ???????? ???????? ?? ?????? ??? ?? ??????? ???????, ? ???? ????????? ???????????
358            str.append( r_msg.getMessageData() );
359            emit MergeDocWithTemplates( false, str);
360        }
361        break;
362    case VPrn::Ans_CreateFormatedDoc:{
363            emit MergeDocWithTemplates( true,
364                                        QObject::trUtf8("?????????? ??????? ? ???????? ?????????, ??????? ?????????!"));
365        }
366        break;
367    case VPrn::Ans_ConvertFormatedDocToPng:{
368            emit PicturesList( r_msg.getMessageDataList() );
369        }
370        break;
371    case VPrn::GoodBay:{
372            str.append(r_msg.getMessageData());
373            emit reciveGoodBayMsg(str);
374        }
375        break;
376    case VPrn::Ans_MB_NOT_EXIST:{
377            //???????? ?? ??????????????? ? ?? ?????
378            // ????????? ?????? ?? ??????????? ?????????
379            registerMB();
380        }
381        break;
382    case VPrn::Ans_MB_EXIST_AND_BRAK:{
383            //???????? ??????????????? ? ?? ?????
384            str.append(r_msg.getMessageData());
385            emit RegisterDocInBase( true, str);
386        }
387        break;
388    case VPrn::Ans_MB_EXIST_AND_NOT_BRAK:{
389            //???????? ??????????????? ? ?? ?????
390            str.append(r_msg.getMessageData());
391            emit RegisterDocInBase( false, str);
392        }
393        break;
394    case VPrn::Ans_RegisterDocInBase:{
395            //???????? ??????????????? ? ?? ?????
396            str.append(r_msg.getMessageData());
397            emit RegisterDocInBase( true, str);
398        }
399        break;
400    case VPrn::Ans_MB_LIST:{
401        }
402        break;
403    case VPrn::Ans_PRINT_ALLOWED:{
404            str.append(r_msg.getMessageData());
405            emit authToDevice( true,str );
406        }
407        break;
408                case VPrn::Ans_PRINT_DENIED:{
409                        str.append(r_msg.getMessageData());
410                        emit authToDevice( false,str );
411                    }
412                    break;
413                case VPrn::Ans_PRINTER_NOT_FOUND:{
414                        str.append(r_msg.getMessageData());
415                        emit authToDevice( false,str );
416                    }
417                    break;
418                case VPrn::Ans_Convert2PdfFinish:{
419                        emit doc_converted();
420                    }
421                    break;
422                case VPrn::Ans_PageCounting:{
423                        str.append(r_msg.getMessageData()); // ????? ??????? ? str
424                        int pCnt = str.toInt();
425                        setPageCountInModel(pCnt);
426                    }
427                    break;
428                case VPrn::Ans_PRINTER_LIST:{
429                        str.append(r_msg.getMessageData());
430                        savePrintersListToModel( str );
431                        emit RecivePrintersList();
432                    }
433                    break;
434                case VPrn::Ans_STAMP_LIST:{
435                        // ???????? ???????? ??????? ???????????, ???????? ? ??????
436                        str.append(r_msg.getMessageData());
437                        setSecLevelList(QStringList() << str.split(";:;") );
438                        emit ReciveSecLevelList();
439                        //?????? ?????? ????????? ????????? ?????????????
440                        msg.setType(VPrn::Que_GET_PRINTER_LIST);
441                        sendMessage2LocalSrv(msg);
442                    }
443                    break;
444
445                case VPrn::Err_Message:{
446                        // ???????? ????????? ?? ?????? ??????: ???~~????????
447                    }
448                    break;
449                default:
450                    break;
451                }
452}
453
454//-------------------------------------- PRIVATE ----------------------------------------
455void Engine::sendMessage2LocalSrv(const Message &s_msg)
456{
457    if (m_LocalClient){
458        m_LocalClient->sendMessage(s_msg);
459    }
460}
461
462void Engine::afterConnectSteps()
463{
464    Message msg(this);
465    msg.setType( VPrn::Que_GiveMeTemplatesList );
466    sendMessage2LocalSrv( msg );
467
468    emit RemoteDemonRegistr();
469}
470
471void Engine::savePrintersListToModel(const QString &prn_list)
472{
473    // ???????? ????? ???????, ? ???????: ???????? ????????;:;???????? ????????2;;:???????? ????????_
474    
475    QStringList printers_item = prn_list.split(";:;");
476    for (int i = 0; i < printers_item.size(); i++) {
477	m_Prn_model->setItem(i, 0, new QStandardItem(printers_item.at(i)));
478    }
479}
480
481void Engine::saveTemplatesListToModel(QByteArray tmpl_list)
482{
483    if ( m_Tmpl_model && !tmpl_list.isEmpty() ){
484        //????????? ??????
485        QDataStream in(&tmpl_list, QIODevice::ReadOnly );
486        in.setVersion(QDataStream::Qt_3_0);
487        int rows;
488        int columns;
489        in >> rows;
490        in >> columns;
491        QString txt;
492        for (int i=0;i<rows;i++){
493            for (int j=0;j<columns;j++){
494                in >> txt;
495                m_Tmpl_model->setItem(i,j,new QStandardItem(txt));
496                txt.clear();
497            }
498        }
499    }
500}
501
502void Engine::setSecLevelList(QStringList  &list )
503{
504    if (list.size() >0  && m_Stamp_model !=0){
505        m_Stamp_model->setStringList( list );
506    }
507}
508
509void Engine::setPageCountInModel(int pCnt)
510{
511    m_DC_model->setItem(0,VPrn::cards_PAGE_COUNT,
512                        new QStandardItem(QObject::trUtf8("%1").arg(pCnt,0,10))
513                        );
514}
515
516QString Engine::findPrinterInModel()
517{
518    QString device_profile;
519    for (int i=0; i< m_Prn_model->rowCount();i++){
520        QModelIndex index = m_Prn_model->index(i,3);
521        bool sel_flag = m_Prn_model->data(index,Qt::DisplayRole).toBool();
522        if (sel_flag){
523            QModelIndex index_name = m_Prn_model->index(i, 0);
524            //QModelIndex index_qqueue = m_Prn_model->index(i, 2);
525
526            device_profile = m_Prn_model->data(index_name, Qt::DisplayRole).toString();
527            break;
528
529        }
530    }
531    return device_profile;
532}
533
534QByteArray Engine::getAllFieldData()
535{
536    QMap <int,QString> m_tagValue;
537    QModelIndex indx;
538    QByteArray fields_data;
539    QList <int> doc_copyes;
540    QString t_fileName;
541
542    for (int j=0;j<m_DC_model->columnCount();j++){
543        indx = m_DC_model->index(0,j);
544        QVariant cell_data = m_DC_model->data(indx,Qt::DisplayRole);
545        QString tmp_item = cell_data.toString();
546        //qDebug() <<Q_FUNC_INFO << "\ncell_data: " << tmp_item;
547        if (!cell_data.isNull()){
548            switch (j){
549            case VPrn::cards_DOC_NAME:
550                m_tagValue[VPrn::cards_DOC_NAME] = cell_data.toString();
551                break;
552            case VPrn::cards_MB_NUMBER:
553                m_tagValue[VPrn::cards_MB_NUMBER] = cell_data.toString();
554                break;
555            case VPrn::cards_STAMP:
556                m_tagValue[VPrn::cards_STAMP] = findStampInModel(cell_data.toInt());
557                break;
558            case VPrn::cards_PUNKT:
559                m_tagValue[VPrn::cards_PUNKT] = cell_data.toString();
560                break;
561            case VPrn::cards_PAGE_COUNT:
562                m_tagValue[VPrn::cards_PAGE_COUNT] = cell_data.toString();
563                break;
564            case VPrn::cards_EXECUTOR:
565                m_tagValue[VPrn::cards_EXECUTOR] = cell_data.toString();
566                break;
567            case VPrn::cards_PRINTMAN:
568                m_tagValue[VPrn::cards_PRINTMAN] = cell_data.toString();
569                break;
570            case VPrn::cards_PHONE:
571                m_tagValue[VPrn::cards_PHONE] = cell_data.toString();
572                break;
573            case VPrn::cards_INV_NUMBER:
574                m_tagValue[VPrn::cards_INV_NUMBER] = cell_data.toString();
575                break;
576            case VPrn::cards_PRINT_DATE:
577                m_tagValue[VPrn::cards_PRINT_DATE] = cell_data.toString();
578                break;
579            case VPrn::cards_RECIVER_1:
580                m_tagValue[VPrn::cards_RECIVER_1] = cell_data.toString();
581                doc_copyes.append(VPrn::FirstPage);
582                break;
583            case VPrn::cards_RECIVER_2:
584                m_tagValue[VPrn::cards_RECIVER_2] = cell_data.toString();
585                doc_copyes.append(VPrn::FirstPageN2);
586                break;
587            case VPrn::cards_RECIVER_3:
588                m_tagValue[VPrn::cards_RECIVER_3] = cell_data.toString();
589                doc_copyes.append(VPrn::FirstPageN3);
590                break;
591            case VPrn::cards_RECIVER_4:
592                m_tagValue[VPrn::cards_RECIVER_4] = cell_data.toString();
593                doc_copyes.append(VPrn::FirstPageN4);
594                break;
595            case VPrn::cards_RECIVER_5:
596                m_tagValue[VPrn::cards_RECIVER_5] = cell_data.toString();
597                doc_copyes.append(VPrn::FirstPageN5);
598                break;
599            case VPrn::cards_TEMPLATE_NAME:
600                t_fileName =  findTemplatesFilePathInModel(cell_data.toInt());
601                break;
602            case VPrn::cards_CURRENT_COPY:
603                m_tagValue[VPrn::cards_CURRENT_COPY] = cell_data.toString();
604                break;
605            default:
606                break;
607            }
608        }
609    }
610
611    m_tagValue[VPrn::cards_COPY_COUNT]= QString("%1")
612                                        .arg(doc_copyes.count(),0,10) ;
613
614
615    //??????? ?????????
616    fields_data.clear();
617    QDataStream out(&fields_data, QIODevice::WriteOnly );
618    out.setVersion(QDataStream::Qt_3_0);
619    //??????? ???? ????????? ????????????? ?????????,????? ???????????
620    //out << qMakePair(cur_copyes,all_copyes);
621    out <<  doc_copyes;
622    // ??????? ????????? ????????????? ??????
623    out << t_fileName;
624    // save map
625    out << m_tagValue;
626
627    return fields_data;
628}
629
630
631QString Engine::findTemplatesFilePathInModel ( int id )
632{
633    QModelIndex indx = m_Tmpl_model->index(id,VPrn::metaInfo_fname);
634    return m_Tmpl_model->data(indx,Qt::DisplayRole).toString();
635}
636
637QString Engine::findStampInModel ( int id )
638{
639    QModelIndex indx = m_Stamp_model->index(id,0);
640    return m_Stamp_model->data(indx,Qt::DisplayRole).toString();
641}