MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Utility / cardselect.cpp
blob84a40010d6b30cb6869e5d53873cb12cb58c1578
1 /*
2 ***************************************************************************
3 * Ralink Tech Inc.
4 * 4F, No. 2 Technology 5th Rd.
5 * Science-based Industrial Park
6 * Hsin-chu, Taiwan, R.O.C.
8 * (c) Copyright 2002, Ralink Technology, Inc.
10 * All rights reserved. Ralink's source code is an unpublished work and the
11 * use of a copyright notice does not imply otherwise. This source code
12 * contains confidential trade secret material of Ralink Tech. Any attemp
13 * or participation in deciphering, decoding, reverse engineering or in any
14 * way altering the source code is stricitly prohibited, unless the prior
15 * written consent of Ralink Technology, Inc. is obtained.
16 ***************************************************************************
18 Module Name:
19 cardselect.cpp
21 Abstract:
22 Implement card select Dialog.
24 Revision History:
25 Who When What
26 -------- ---------- ----------------------------------------------
27 Paul Wu 01-22-2003 created
28 Paul Wu 11-10-2003 Modify for RT2500 ApConfig
32 #include "cardselect.h"
33 #include "rt_tool.h"
35 #include <qapplication.h>
36 #include <qvariant.h>
37 #include <qheader.h>
38 #include <qlistview.h>
39 #include <qlabel.h>
40 #include <qpushbutton.h>
41 #include <qmime.h>
42 #include <qdragobject.h>
43 #include <qlayout.h>
44 #include <qtooltip.h>
45 #include <qwhatsthis.h>
46 #include <qimage.h>
47 #include <qpixmap.h>
48 #include <qmessagebox.h>
50 static QPixmap uic_load_pixmap_CardSelect( const QString &name )
52 const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( name );
53 if ( !m )
54 return QPixmap();
55 QPixmap pix;
56 QImageDrag::decode( m, pix );
57 return pix;
59 /*
60 * Constructs a CardSelect which is a child of 'parent', with the
61 * name 'name' and widget flags set to 'f'.
63 * The dialog will by default be modeless, unless you set 'modal' to
64 * TRUE to construct a modal dialog.
66 CardSelect::CardSelect( int Socket_Id, PRT_DEVICE_ADAPTER prtAdapter, QWidget* parent, const char* name, bool modal, WFlags fl )
67 : QDialog( parent, name, modal, fl )
69 if ( !name )
70 setName( "CardSelect" );
71 resize( 493, 224 );
72 setMinimumSize( 493, 224 );
73 setMaximumSize( 493, 224 );
74 setCaption("Select Wireless Adapter");
76 qApp->setStyle("Windows");
78 TextLabel1 = new QLabel(this, "TextLabel1" );
79 TextLabel1->setGeometry( QRect( 20, 20, 400, 20 ) );
80 TextLabel1->setText("Please select a adapter to configure :");
82 OkPushButton = new QPushButton( this, "OkPushButton" );
83 OkPushButton->setGeometry( QRect( 216, 180, 60, 30 ) );
84 OkPushButton->setText("&Ok");
86 AdapterListView = new QListView( this, "AdapterListView" );
87 AdapterListView->addColumn("");
88 AdapterListView->addColumn(" Device Name ");
89 AdapterListView->addColumn(" Type ");
90 AdapterListView->addColumn(" MAC Address ");
91 AdapterListView->setGeometry( QRect( 20, 50, 450, 111 ) );
92 AdapterListView->setSelectionMode( QListView::Single );
93 AdapterListView->setHScrollBarMode( QListView::AlwaysOn );
94 AdapterListView->setAllColumnsShowFocus( TRUE );
96 QListViewItem *Item;
97 int first=TRUE;
98 char tmp[40];
99 int index=1;
101 while(prtAdapter)
103 Item = new QListViewItem(AdapterListView, 0);
104 sprintf(tmp, " %d ", index++);
105 Item -> setText(0, tmp);
106 Item -> setPixmap(0, uic_load_pixmap_CardSelect("adapter.xpm"));
107 Item -> setText(1, (const char *)prtAdapter->Device_Name);
108 Item -> setText(2, " Wireless Ethernet ");
109 NDIS_802_11_MAC_ADDRESS CurrentAddress;
111 if( OidQueryInformation(OID_802_3_CURRENT_ADDRESS, Socket_Id, prtAdapter->Device_Name, &CurrentAddress, sizeof(CurrentAddress)) >= 0)
113 sprintf(tmp, "%02X-%02X-%02X-%02X-%02X-%02X", CurrentAddress[0], CurrentAddress[1],
114 CurrentAddress[2], CurrentAddress[3], CurrentAddress[4], CurrentAddress[5]);
115 Item -> setText(3, (const char *)tmp);
118 if(first)
120 AdapterListView->setSelected(Item, TRUE);
121 first=FALSE;
123 prtAdapter = prtAdapter->Next;
126 // signals and slots connections
127 connect( OkPushButton, SIGNAL( clicked() ), this, SLOT( OkPushButton_Clicked() ) );
128 connect( AdapterListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( AdapterListView_doubleClicked() ) );
130 bClickOk = FALSE;
134 * Destroys the object and frees any allocated resources
136 CardSelect::~CardSelect()
138 // no need to delete child widgets, Qt does it all for us
141 void CardSelect::AdapterListView_doubleClicked()
143 OkPushButton_Clicked();
146 const char *CardSelect::Get_Device_Name()
148 return device.ascii();
151 void CardSelect::OkPushButton_Clicked()
153 QListViewItem *Item;
154 QString str;
156 Item = AdapterListView->currentItem();
157 if(Item == NULL)
159 QMessageBox::warning(this, "Warning", "Please select a adapter first.!");
160 return ;
162 device=Item->text(1);
163 bClickOk = TRUE;
164 close();
167 bool CardSelect::isClickOk()
169 return (bClickOk);