ListDialog.cxx
Go to the documentation of this file.
1 
12 #include "ListDialog.h"
13 
14 #if QT_VERSION < 0x040000
15 #include <qlistview.h>
16 #else
17 #include <q3listview.h>
18 #endif
19 
20 using std::string;
21 
22 using namespace hippodraw;
23 
24 // #if QT_VERSION < 0x040000
26 ListDialog ( QWidget * parent )
27  : ListDialogBase ( parent )
28 {
29 }
30 // #else
31 // ListDialog::
32 // ListDialog ( QWidget * parent )
33 // : QDialog ( parent )
34 // {
35 // setupUi ( this );
36 // }
37 // #endif
38 
39 void
41 setNames ( const std::vector < std::string > & names )
42 {
43  for ( unsigned int i = 0; i < names.size (); i++ ) {
44  const string & n = names[i];
45  QString name ( n.c_str() );
46 #if QT_VERSION < 0x040000
48  = new QListViewItem ( m_tuple_list,
49  QString ( "%1" ).arg ( i+1 ),
50  QString ( name ) );
51 #else
52  Q3ListViewItem * item
53  = new Q3ListViewItem ( m_tuple_list,
54  QString ( "%1" ).arg ( i+1 ),
55  QString ( name ) );
56 #endif
57  m_item_list.push_back ( item );
58  }
59 #if QT_VERSION < 0x040000
60  m_tuple_list -> setSelectionMode ( QListView::Single );
61 #else
62  m_tuple_list -> setSelectionMode ( Q3ListView::Single );
63 #endif
64  m_tuple_list ->setSelected ( m_item_list[0], true );
65 }
66 
67 unsigned int
69 selectedItem () const
70 {
71  unsigned int index = m_item_list.size(); // one too many
72  for ( unsigned int i = 0; i < m_item_list.size(); i++ ) {
73 #if QT_VERSION < 0x040000
75 #else
76  Q3ListViewItem * item = m_item_list[i];
77 #endif
78  if ( item -> isSelected () ) {
79  index = i;
80  break;
81  }
82  }
83 
84  return index;
85 }
86 
87 void
90 {
91  accept ();
92 }
virtual void doubleClicked()
Responds to a double click on the contained QListView object.
Definition: ListDialog.cxx:89
unsigned int i
QListViewItem * item
Definition: PickTable.cxx:172
unsigned int selectedItem() const
Returns the index of the selected item.
Definition: ListDialog.cxx:69
void setNames(const std::vector< std::string > &names)
Sets the names of the of the top level objects that might be valid DataSource objects.
Definition: ListDialog.cxx:41
The base class for the ListDialog class.
std::vector< QListViewItem * > m_item_list
The list of items added to the list of data source names.
Definition: ListDialog.h:55
hippodraw::ListDialog class interface
QListView * m_tuple_list
setSelected(QListViewItem *item, bool selected)
return index
Definition: PickTable.cxx:182
ListDialog(QWidget *parent)
The constructor.
Definition: ListDialog.cxx:26

Generated for HippoDraw Class Library by doxygen