#include <QtGui>
#include "mainfrm.h"

void mainfrm::f_swap_swap(int cpt1, int cpt2)
{
        QLabel *mylabel;
        QString tmp_tab[1][nbre_occurs];
	QLabel *tmppnt;
        QColor tmpcolor[2];

     	mylabel = table_pnt_img[cpt1];
	//
       	mylabel->setGeometry( (((cpt2) * 97) + ((cpt2+1) * 10)) , 0 , 97, 77);
        // *** Decalage des pointeurs et autres ***
        tmppnt = table_pnt_img[cpt1];

	int wl_cpt_001 = 0;
	while ( wl_cpt_001 < nbre_occurs )
	{
        	tmp_tab[0][wl_cpt_001] = table_photos[cpt1][wl_cpt_001];
		++wl_cpt_001;
	}
	tmpcolor[0] = table_color_fog[cpt1];
	//
        mylabel = table_pnt_img[cpt2];
	//
        mylabel->setGeometry( ((((cpt1) * 97)) + ((cpt1+1) * 10)), 0 , 97, 77);
        // *** Decalage des pointeurs et autres ***
        table_pnt_img[cpt1] = table_pnt_img[cpt2];
	wl_cpt_001 = 0;
	while ( wl_cpt_001 < nbre_occurs )
	{
        	table_photos[cpt1][wl_cpt_001] = table_photos[cpt2][wl_cpt_001];
		++wl_cpt_001;
	}
	table_color_fog[cpt1] = table_color_fog[cpt2];
	//
        table_pnt_img[cpt2] = tmppnt;
	wl_cpt_001 = 0;
	while ( wl_cpt_001 < nbre_occurs )
	{
        	table_photos[cpt2][wl_cpt_001] = tmp_tab[0][wl_cpt_001];
		++wl_cpt_001;
	}
	table_color_fog[cpt2] = tmpcolor[0];
}

void mainfrm::f_dep_droite()
{
	must_redraw = 0;
// *** Deplacement images vers droite ***
    	if ( nbre_photos > 0 )
    	{
        	int cpt1;
        	QLabel *mylabel;
        	QString tmp_tab[1][nbre_occurs];
		QLabel *tmppnt;
        	cpt1 = current_diapo;
        	QColor tmpcolor[2];

        	if ( nbre_photos > 0 && current_diapo < nbre_photos )
        	{
            		mylabel = table_pnt_img[cpt1];
		        //
        		mylabel->setGeometry( (((cpt1 + 1) * 97) + ((cpt1 + 2) * 10)) , 0 , 97, 77);
			img_selection->setGeometry( (((cpt1 + 1) * 97) + ((cpt1 + 2) * 10))-5, 0, 30, 30);
			QRect mypoint = pnttimeline->geometry();
			if ( (((cpt1 + 1) * 97) + ((cpt1 + 1) * 10)) > ( (mypoint.x() * -1) + 831 ) )
			{
				scroll_timeline->setValue((((cpt1 + 1) * 97) + ((cpt1 + 1) * 10)));
			}
            		// *** Decalage des pointeurs et autres ***
            		tmppnt = table_pnt_img[cpt1];

			int wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			tmp_tab[0][wl_cpt_001] = table_photos[cpt1][wl_cpt_001];
				++wl_cpt_001;
			}
			tmpcolor[0] = table_color_fog[cpt1];
			//
            		mylabel = table_pnt_img[cpt1 + 1];
		        //
        		mylabel->setGeometry( ((cpt1 * 97) + ((cpt1+1) * 10)), 0 , 97, 77);
            		// *** Decalage des pointeurs et autres ***
            		table_pnt_img[cpt1] = table_pnt_img[cpt1 + 1];

			wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			table_photos[cpt1][wl_cpt_001] = table_photos[cpt1 + 1][wl_cpt_001];
				++wl_cpt_001;
			}

 			table_color_fog[cpt1] = table_color_fog[cpt1 + 1];
			//
            		table_pnt_img[cpt1 + 1] = tmppnt;

			wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			table_photos[cpt1 + 1][wl_cpt_001] = tmp_tab[0][wl_cpt_001];
				++wl_cpt_001;
			}

			table_color_fog[cpt1 + 1] = tmpcolor[0];
			//
			//tmpcolor[1] = pntmygl->table_color[cpt1];
			//pntmygl->table_color[cpt1] = pntmygl->table_color[cpt1+1];
			//pntmygl->table_color[cpt1+1] = tmpcolor[1];
			//
            		current_diapo = cpt1 + 1;
		}
        }
}

void mainfrm::f_dep_gauche()
{
	must_redraw = 0;
// *** Deplacement images vers gauche ***
    	if ( nbre_photos > 0 )
    	{
        	int cpt1;
        	QLabel *mylabel;
        	QString tmp_tab[1][nbre_occurs];
		QLabel *tmppnt;
        	cpt1 = current_diapo;
		QColor tmpcolor[2];
        
        	if ( nbre_photos > 0 && current_diapo > 0 )
        	{
            		mylabel = table_pnt_img[cpt1];
		        //
        		mylabel->setGeometry( (((cpt1 - 1) * 97) + (cpt1 * 10)) , 0 , 97, 77);
			img_selection->setGeometry( (((cpt1 - 1) * 97) + (cpt1 * 10))-5, 0, 30, 30);
			QRect mypoint = pnttimeline->geometry();
			if ( (((cpt1 - 1) * 97) + ((cpt1 - 1) * 10)) < (mypoint.x() * -1) )
			{
				if ( (((cpt1 - 1) * 97) + ((cpt1 - 1) * 10)) > 831 )
				{
					scroll_timeline->setValue((((cpt1 - 1) * 97) + (cpt1 * 10)));
				}
				else
				{
					scroll_timeline->setValue(0);
				}
			}
            		// *** Decalage des pointeurs et autres ***
            		tmppnt = table_pnt_img[cpt1];
			int wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			tmp_tab[0][wl_cpt_001] = table_photos[cpt1][wl_cpt_001];
				++wl_cpt_001;
			}

			tmpcolor[0] = table_color_fog[cpt1];
			//
            		mylabel = table_pnt_img[cpt1 - 1];
		        //
        		mylabel->setGeometry( ((cpt1 * 97) + ((cpt1 + 1) * 10)), 0 , 97, 77);
            		// *** Decalage des pointeurs et autres ***
            		table_pnt_img[cpt1] = table_pnt_img[cpt1 - 1];

			wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			table_photos[cpt1][wl_cpt_001] = table_photos[cpt1 - 1][wl_cpt_001];
				++wl_cpt_001;
			}

			table_color_fog[cpt1] = table_color_fog[cpt1 - 1];
			//
            		table_pnt_img[cpt1 - 1] = tmppnt;

			wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
        			table_photos[cpt1 - 1][wl_cpt_001] = tmp_tab[0][wl_cpt_001];
				++wl_cpt_001;
			}

			table_color_fog[cpt1 - 1] = tmpcolor[0];
			//
			//tmpcolor[1] = pntmygl->table_color[cpt1];
			//pntmygl->table_color[cpt1] = pntmygl->table_color[cpt1-1];
			//pntmygl->table_color[cpt1-1] = tmpcolor[1];
			//
            		current_diapo = cpt1 - 1;
		}
        }
}
