]> rtime.felk.cvut.cz Git - orte.git/blob - orte/contrib/shape/MulticlipForm.ui.h
OCERA SF CVS tree of ORTE framework updated to
[orte.git] / orte / contrib / shape / MulticlipForm.ui.h
1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
3 **
4 ** If you wish to add, delete or rename slots use Qt Designer which will
5 ** update this file, preserving your code. Create an init() slot in place of
6 ** a constructor, and a destroy() slot in place of a destructor.
7 *****************************************************************************/
8 #include <orte_api.h>
9 #include <qwidget.h>
10 Subscriber *tabSub[50];
11 int NSubscriber;
12 Publisher *tabPub[50];
13 int NPublisher;
14 int np,ns;
15
16 void MulticlipForm::init()
17 {
18         memset(tabSub,0,sizeof(tabSub));
19         memset(tabPub,0,sizeof(tabPub));
20         NPublisher=0;
21         NSubscriber=0;
22         np=ns=1;
23         QTimer *timer = new QTimer(this);
24         connect( timer, SIGNAL(timeout()), SLOT(Timer()));
25         timer->start( 500, FALSE );
26 }
27
28
29 void MulticlipForm::addPublisher()
30 {
31         PublishersListBox->insertItem( QString::number(np), 0 );
32         GotoP();
33         NPublisher++;
34 }
35
36
37
38 void MulticlipForm::deletePublisher()
39 {
40         QString  text=PublishersListBox->currentText();
41         if(PublishersListBox->currentItem()!=-1 && !text.isEmpty()){
42                 int pub;
43                 pub=NPublisher-1-PublishersListBox->currentItem() ;
44                 PublishersListBox->removeItem( PublishersListBox->currentItem() );
45                 tabPub[pub]->Destroy();
46                 delete(tabPub[pub]);
47                 for(int i=pub;i+1<NPublisher;i++) tabPub[i]=tabPub[i+1];
48                 tabPub[NPublisher]=NULL;
49                 NPublisher--;
50         }
51 }
52
53
54 void MulticlipForm::GotoP(  )
55 {
56     QString name = QString::number(np);
57         np++;
58     int shap=ShapeP->currentItem();
59     int color=ColorP->currentItem();
60     int strength=0;
61    tabPub[NPublisher]=new Publisher();
62    tabPub[NPublisher]->Create(name,shap,color,strength);
63 }
64
65
66
67 void MulticlipForm::closeEvent( QCloseEvent *e )
68 {
69         int i;
70     for(i=0;i<NPublisher;i++){
71          tabPub[i]->Destroy();
72          delete(tabPub[i]);
73      }
74     for(i=0;i<NSubscriber;i++){
75          tabSub[i]->Destroy();
76          delete(tabSub[i]);
77      }
78 e->accept();
79 }
80
81 void MulticlipForm::GotoS(  )
82 {
83     QString name =QString::number(ns);
84     ns++;
85     tabSub[NSubscriber]=new Subscriber();
86     tabSub[NSubscriber]->Create(name,
87                                 clBlue->isChecked(),
88                                 clGreen->isChecked(),
89                                 clRed->isChecked(),
90                                 clBlack->isChecked(),
91                                 clYellow->isChecked());
92 }
93
94 void MulticlipForm::addSubscriber()
95 {
96         
97         SubscribersListBox->insertItem( QString::number(ns), 0 );
98         GotoS();
99         NSubscriber++;
100 }
101
102
103 void MulticlipForm::deleteSubscriber()
104 {
105 QString  text=SubscribersListBox->currentText();
106         if(SubscribersListBox->currentItem()!=-1 && !text.isEmpty()){
107                 int pub;
108                 pub=NSubscriber-1-SubscribersListBox->currentItem() ;
109                 SubscribersListBox->removeItem( SubscribersListBox->currentItem() );
110                 tabSub[pub]->Destroy();
111                 delete(tabSub[pub]);
112                 for(int i=pub;i+1<NSubscriber;i++) tabSub[i]=tabSub[i+1];
113                 tabSub[NSubscriber]=NULL;
114                 NSubscriber--;
115         }
116 }
117
118
119
120 void MulticlipForm::keyPressEvent( QKeyEvent *e )
121 {    
122     if(Qt::Key_Delete==e->key() ) {
123                 if( focusWidget ()==PublishersListBox)deletePublisher();
124                 if( focusWidget ()==SubscribersListBox)deleteSubscriber();
125     }
126 }
127
128
129
130 void MulticlipForm::Timer()
131 {
132         int i;
133         for(i=0;i<NPublisher;i++){
134                 if((tabPub[i]->m_mainFrm)->getClose()==1){
135                         PublishersListBox->setCurrentItem (NPublisher-1-i);
136                         deletePublisher();
137                 }
138         }
139         for(i=0;i<NSubscriber;i++){
140                 if((tabSub[i]->m_mainFrm)->getClose()==1){
141                         SubscribersListBox->setCurrentItem (NSubscriber-1-i);
142                         deleteSubscriber();
143                 }
144         }
145 }