void TASARIM_BELGE_DEGISKENLERI_SECIMI::FILL_TABLE()
{
    QTableWidget *table_widget = GET_TABLE_WIDGET();

    int current_row = 0;

    for (int i = 0; i < m_degisken_listesi.size(); ++i) {

        current_row = ADD_NEW_ROW();

        TASARIM_DEGISKENI *degisken = m_degisken_listesi.at(i);

        table_widget->item(current_row, 0 )->setText ( QString::number( current_row ) );

        if ( degisken->GET_DEGISKEN_TYPE() NE USER_VARIABLE ) {
            QString degisken_text = degisken->GET_TEXT();

            degisken_text.prepend("[");
            degisken_text.append("]");

            if( degisken->GET_GRUP() EQ LINE ) {
                degisken_text.prepend("[");
                degisken_text.append("]");
            }

            table_widget->item(current_row, 1 )->setText ( degisken_text );
        }
        else {
            table_widget->item(current_row, 1 )->setText ( degisken->GET_TEXT() );
        }
    }
}
void TASARIM_BATCH_BASE::SLOT_TEXT_EKLE_BUTTON_CLICKED()
{
    m_design_widget->RESET_VARIABLE();

    QDialog     * dialog      = new QDialog;
    QGridLayout * box_layout  = new QGridLayout;
    QLabel      * label       = new QLabel;
    QLineEdit   * line_edit   = new QLineEdit;
    QComboBox   * combobox_grup = new QComboBox;
    QPushButton * push_button = new QPushButton("Yazı Ekle");

    line_edit->setMinimumWidth(350);

    combobox_grup->addItem(tr("Add the Form "));
    combobox_grup->addItem("Add the Line");

    dialog->setLayout     (box_layout);
    box_layout->addWidget (label,         0, 0);
    box_layout->addWidget (line_edit,     0, 1);
    box_layout->addWidget (push_button,   0, 2);
    box_layout->addWidget (combobox_grup, 1, 1);

    combobox_grup->setVisible(false);

    connect( push_button, SIGNAL(clicked()), dialog, SLOT(close()));

    dialog->exec();

    if ( line_edit->text().isEmpty() EQ true ) {
        return;
    }

//    int text_grup = combobox_grup->currentIndex();

    QLabel * user_label = m_design_widget->CREATE_NEW_LABEL(line_edit->text());

    TASARIM_DEGISKENI * degisken =  new TASARIM_DEGISKENI(true);

    degisken->SET_TASARIM_ID( m_tasarim_id );
    degisken->SET_TEXT( line_edit->text() );
    degisken->SET_TEXT_SIZE( line_edit->text().size() ); // txt uzunlugu kadar
    degisken->SET_GRUP( USER_TEXT);

//    if ( text_grup EQ 0 ) {
//        degisken->SET_GRUP( USER_TEXT);
//    }
//    else {
//        degisken->SET_GRUP(LINE);
//    }
    degisken->SET_BELGE_DEGISKEN_ID( -1 );
    degisken->SET_DEGISKEN_ID(-1);

    degisken->SET_FONT_SIZE( 11 );
    if ( m_printer_type EQ DOT_MATRIX_PRINTER ) {
        degisken->SET_FONT_SIZE( 10 );
    }

    degisken->SET_ALIGN( 10 );
    degisken->SET_VISIBLE( true );
    degisken->SET_POS_X( 0.00 );
    degisken->SET_POS_Y( 0.00 );
    degisken->SET_SIZE_X( 0 );
    degisken->SET_SIZE_Y( 0 );

    degisken->SET_LABEL( user_label );

    if ( m_printer_type EQ DOT_MATRIX_PRINTER ) {
        degisken->SET_FONT_FAMILY("Monospace");
    }

    QFont font = user_label->font();
    font.setFamily(degisken->GET_FONT_FAMILY());
    user_label->setFont(font);

    user_label->setObjectName( QString::number( degisken->GET_PRIMARY_ID())+ "\t"+QString::number( degisken->GET_GRUP() ) );

    m_all_variables.append( degisken );

    m_design_widget->ADD_NEW_VARIABLE( 0, 0, user_label );

}
void TASARIM_BATCH_BASE::SLOT_RESIM_EKLE_BUTTON_CLICKED()
{
    m_design_widget->RESET_VARIABLE();

    QString file_name = QFileDialog::getOpenFileName( NULL, tr("Open Picture"), "", tr("Picture File (*.png *.jpg *.bmp)"));

    if ( file_name.isEmpty() EQ true ) {
        return;
    }

    QLabel * user_label = m_design_widget->CREATE_NEW_LABEL("");

    user_label->setPixmap(file_name);
    user_label->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored  );
    user_label->setScaledContents(true);

    TASARIM_DEGISKENI * degisken =  new TASARIM_DEGISKENI(true);

    degisken->SET_TASARIM_ID( m_tasarim_id );
    degisken->SET_TEXT( file_name );
    degisken->SET_GRUP( USER_IMG );
    degisken->SET_BELGE_DEGISKEN_ID( -1 );
    degisken->SET_FONT_SIZE( 13 );
    degisken->SET_ALIGN( 10 );
    degisken->SET_VISIBLE( true );
    degisken->SET_POS_X( 0.00 );
    degisken->SET_POS_Y( 0.00 );
    degisken->SET_SIZE_X( 30 );
    degisken->SET_SIZE_Y( 30 );
    degisken->SET_IMAGES( *user_label->pixmap() );
    degisken->SET_LABEL( user_label );
    degisken->SET_DEGISKEN_ID(-1);

    user_label->setObjectName( QString::number(degisken->GET_PRIMARY_ID() ) + "\t"+ QString::number( degisken->GET_GRUP() ) );

    m_all_variables.append( degisken );

    m_design_widget->ADD_NEW_VARIABLE(0, 0, user_label);
}
void BELGE_KERNEL::ADD_VARIABLES()
{

    ADAK_BELGE_DEFAULTS_STRUCT * belge_struct = new ADAK_BELGE_DEFAULTS_STRUCT;

    // degiskenler once siralanmali ------------> satirlar
/*    1....N
      --------->
 N+1  |
      |
      |
 N+M  v

*/

    if ( m_printer_type EQ DOT_MATRIX_PRINTER ) {
        QList<TASARIM_DEGISKENI*> sirali_liste;

        for (int k = 0; k < m_belge_satir_count; ++k) {
            int aranan_satir = k;

            QList<TASARIM_DEGISKENI*> satirdaki_degiskenler;
            for (int i = 0; i < m_all_variables.size(); ++i) {
                TASARIM_DEGISKENI *aranan_degisken = m_all_variables.at(i);
                if ( aranan_degisken->GET_SATIR() EQ aranan_satir ) {
                    satirdaki_degiskenler.append(aranan_degisken);
                }
            }
            //! hesaplama

            //! AYNI SATIRDAKI DEGISKENLERI SIRALA ASC

            DEGISLENLERI_SIRALA(&satirdaki_degiskenler);

            sirali_liste.append(satirdaki_degiskenler);
        }

        m_all_variables.clear();

        m_all_variables.append(sirali_liste);
    }

    for ( int i = 0 ; i < m_all_variables.size() ; i++ ) {

        TASARIM_DEGISKENI *degisken = m_all_variables.at(i);

        double x = degisken->GET_POS_X();
        double y = degisken->GET_POS_Y();

        double width  = degisken->GET_SIZE_X();
        double height = degisken->GET_SIZE_Y();

        if (m_printer_type EQ LAZER_PRINTERS) {


            m_painter.setPen( Qt::black);
            QFont font = m_painter.font();
            font.setFamily      (degisken->GET_FONT_FAMILY());
            font.setBold        (degisken->IS_BOLD());
            font.setUnderline   (degisken->IS_UNDER_LINE());
            font.setItalic      (degisken->IS_ITALIC());
            font.setStrikeOut   (degisken->IS_STRIKEOUT());
            font.setPointSize   (degisken->GET_FONT_SIZE());
            m_painter.setFont(font);

            double mmx = m_device_pixel_rate_x * x;
            double mmy = m_device_pixel_rate_y * y;

            if ( degisken->IS_VISIBLE() EQ false ) {
                continue;
            }

            if ( degisken->GET_GRUP() EQ USER_TEXT ) {
                m_painter.drawText(QPointF(mmx,mmy), degisken->GET_TEXT() );
            }
            else if ( degisken->GET_GRUP() EQ USER_IMG ) {
                m_painter.drawImage(QRect(mmx, mmy, width, height), degisken->GET_IMAGES().toImage() );
            }
            else  {

                belge_struct->degisken_id         = degisken->GET_DEGISKEN_ID();
                belge_struct->align               = degisken->GET_ALIGN();
                belge_struct->degisken_adi        = degisken->GET_TEXT().toStdString().c_str();
                belge_struct->karakter_sayisi     = degisken->GET_TEXT_SIZE();
                belge_struct->degisken_kodu       = degisken->GET_KODU().toStdString().c_str();
                belge_struct->font_size           = degisken->GET_FONT_SIZE();
                belge_struct->is_visible_variable = degisken->IS_VISIBLE();
                belge_struct->monospace_mi        = degisken->IS_MONOSPACE_MI();
                belge_struct->x_position          = degisken->GET_POS_X();
                belge_struct->y_position          = degisken->GET_POS_Y();

                if ( degisken->GET_GRUP() EQ HEADER ){
                    ADD_LAZER_VARIABLES( belge_struct, 0, &m_header_variables, HEADER );
                }
                if ( degisken->GET_GRUP() EQ LINE ){
                    ADD_LAZER_VARIABLES( belge_struct, 0, &*m_line_variables, LINE );
                }
                if ( degisken->GET_GRUP() EQ FOOTER ){
                    ADD_LAZER_VARIABLES( belge_struct, 0, &m_footer_variables, FOOTER );
                }
            }
        }
        else {
            if ( degisken->IS_VISIBLE() EQ true) {

                if ( degisken->GET_GRUP() EQ USER_TEXT ) {
                    SET_DOTMATRIX_VALUE( degisken->GET_TEXT(), degisken->GET_SOLDAN_BOSLUK(), degisken->GET_SATIR(), degisken->GET_GRUP(), degisken->IS_NLQ(), degisken->GET_DOT_MARIX_MODE() );
                }

                belge_struct->degisken_id         = degisken->GET_DEGISKEN_ID();
                belge_struct->align               = degisken->GET_ALIGN();
                belge_struct->degisken_adi        = degisken->GET_TEXT().toStdString().c_str();
                belge_struct->karakter_sayisi     = degisken->GET_TEXT_SIZE();
                belge_struct->degisken_kodu       = degisken->GET_KODU().toStdString().c_str();
                belge_struct->font_size           = degisken->GET_FONT_SIZE();
                belge_struct->is_visible_variable = degisken->IS_VISIBLE();
                belge_struct->monospace_mi        = degisken->IS_MONOSPACE_MI();
                belge_struct->x_position          = degisken->GET_SOLDAN_BOSLUK();
                belge_struct->y_position          = degisken->GET_SATIR();

                if ( degisken->GET_GRUP() EQ HEADER ){
                    ADD_DOTMATRIX_VARIABLES(belge_struct,0,&m_header_variables,HEADER, degisken->IS_NLQ(), degisken->GET_DOT_MARIX_MODE() );
                }

                if ( degisken->GET_GRUP() EQ LINE ){
                    ADD_DOTMATRIX_VARIABLES(belge_struct,0,&*m_line_variables,LINE, degisken->IS_NLQ(), degisken->GET_DOT_MARIX_MODE() );
                }

                if ( degisken->GET_GRUP() EQ FOOTER ){
                    ADD_DOTMATRIX_VARIABLES(belge_struct,0,&m_footer_variables,FOOTER, degisken->IS_NLQ(), degisken->GET_DOT_MARIX_MODE());
                }
            }
        }
    }

    delete belge_struct;
}