summaryrefslogtreecommitdiff
path: root/CIAO/examples/Display/NavDisplayGUI_exec/DetailView.cpp
blob: 951256001006d62217201e6b44805c59b0c802c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// $Id$

#include "DetailView.h"
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qtable.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qspinbox.h>


DetailView::DetailView(QWidget *parent, const char *name)
: QWidget(parent, name), current_unit(NULL)
{
  QGridLayout *grid = new QGridLayout(this, 8, 10);

  // Create a label containing a QMovie
  separatorlabel = new QLabel(this, "label0" );

  grid->addMultiCellWidget(separatorlabel, 0, 0, 0, 9);

  QLabel *sem_id_label = new QLabel("FDN:", this);
  grid->addWidget(sem_id_label, 1, 0);
  sem_id_val = new QLineEdit(this);
  sem_id_val->setReadOnly(1);
  grid->addMultiCellWidget(sem_id_val, 1, 1, 1, 7);

  QLabel *descr_label = new QLabel("Description:", this);
  grid->addWidget(descr_label, 2, 0);
  descr_edit = new QLineEdit(this);
  grid->addMultiCellWidget(descr_edit, 2, 2, 1, 7);

  QLabel *x_label = new QLabel("X coordinate:", this);
  grid->addWidget(x_label, 3, 0);
  x_edit = new QSpinBox(this);
  x_edit->setMinValue(0);
  x_edit->setMaxValue(65535);
  grid->addWidget(x_edit, 3, 1);

  QLabel *y_label = new QLabel("Y coordinate:", this);
  grid->addWidget(y_label, 3, 3);
  y_edit = new QSpinBox(this);
  y_edit->setMinValue(0);
  y_edit->setMaxValue(65535);
  grid->addWidget(y_edit, 3, 4);

  QLabel *z_label = new QLabel("Z coordinate:", this);
  grid->addWidget(z_label, 3, 6);
  z_edit = new QSpinBox(this);
  z_edit->setMinValue(0);
  z_edit->setMaxValue(65535);
  grid->addWidget(z_edit, 3, 7);

  // Create a label containing a QMovie
  QString path_to_movie;
  char *ace_root = getenv("ACE_ROOT");
  if(ace_root)
  {
    path_to_movie += ace_root;
    path_to_movie += "/TAO/CIAO/examples/handcrafted/Display/NavDisplayGUI_exec/trolltech.gif";
  }
  else
  {
    path_to_movie = "../NavDisplayGUI_exec/trolltech.gif";
  }
  movie = QMovie(path_to_movie);
  movielabel = new QLabel(this, "label1" );
  movie.connectStatus(this, SLOT(movieStatus(int)));
  movie.connectUpdate(this, SLOT(movieUpdate(const QRect&)));
  movielabel->setFrameStyle( QFrame::Box | QFrame::Plain );
  movielabel->setMovie(movie);
  movielabel->setFixedSize( 128+movielabel->frameWidth()*2,
				  64+movielabel->frameWidth()*2 );
  grid->addMultiCellWidget(new QLabel("", this), 1, 4, 8, 8);
  grid->addMultiCellWidget(movielabel, 1, 4, 9, 9);


  QPushButton *apply = new QPushButton("Apply", this);
  apply->setDefault(1);
  grid->addWidget(apply, 7, 9);

  connect(apply, SIGNAL(clicked()), this, SLOT(apply()));

  QTabWidget *tabs = new QTabWidget(this);


  child_list = new QTable(0, 6, tabs);
  child_list->setSelectionMode(QTable::Single);
  child_list->horizontalHeader()->setLabel(0, "FDN");
  child_list->horizontalHeader()->setLabel(1, "Description");
  child_list->horizontalHeader()->setLabel(2, "X Coordinate");
  child_list->horizontalHeader()->setLabel(3, "Y Coordinate");
  child_list->horizontalHeader()->setLabel(4, "Z Coordinate");
  child_list->horizontalHeader()->setLabel(5, "Color");

  parent_list = new QTable(0, 6, tabs);
  parent_list->setSelectionMode(QTable::Single);
  parent_list->horizontalHeader()->setLabel(0, "FDN");
  parent_list->horizontalHeader()->setLabel(1, "Description");
  parent_list->horizontalHeader()->setLabel(2, "X Coordinate");
  parent_list->horizontalHeader()->setLabel(3, "Y Coordinate");
  parent_list->horizontalHeader()->setLabel(4, "Z Coordinate");
  parent_list->horizontalHeader()->setLabel(5, "Color");

  tabs->addTab(child_list, "Property set &1");
  tabs->addTab(parent_list, "Property set &2");

  grid->addMultiCellWidget(new QLabel(this), 4, 4, 0, 9);
  grid->addMultiCellWidget(tabs, 5, 5, 0, 9);
}


DetailView::~DetailView()
{
}


void
DetailView::currentNode(NavUnit *unit)
{
  UnitLocation loc = unit->getLocation();
  descr_edit->setText(unit->getShortDescr());
  this->updateLocation(loc);
}

void
DetailView::updateLocation(const UnitLocation &loc)
{
  x_edit->setValue(static_cast<int>(loc.x_));
  y_edit->setValue(static_cast<int>(loc.y_));
  z_edit->setValue(static_cast<int>(loc.z_));
}

void
DetailView::apply()
{
}


void
DetailView::movieUpdate( const QRect& )
{
    // Uncomment this to test animated icons on your window manager
    //setIcon( movie.framePixmap() );
}


void
DetailView::movieStatus( int s )
{
    switch ( s ) {
      case QMovie::SourceEmpty:
      case QMovie::UnrecognizedFormat:
	{
	    QPixmap pm("tt-logo.png");
	    movielabel->setPixmap(pm);
	    movielabel->setFixedSize(pm.size());
	}
      break;
      default:
	if ( movielabel->movie() )	 	// for flicker-free animation:
	    movielabel->setBackgroundMode( NoBackground );
    }
}