Isis 3.0 Application Source Code Reference |
Home |
00001 #include "QnetNewPointDialog.h" 00002 00003 #include <QtGui> 00004 #include <algorithm> 00005 00006 #include "iString.h" 00007 #include "SerialNumberList.h" 00008 00009 #include "qnet.h" 00010 00011 using namespace Isis::Qnet; 00012 00013 namespace Isis { 00014 // initialize static variable 00015 QString QnetNewPointDialog::lastPtIdValue = ""; 00016 00017 /** 00018 * QnetNewPointDialog constructor 00019 * @param parent The parent widget for the 00020 * cube points filter 00021 * 00022 * @internal 00023 * @history 2008-11-26 Jeannie Walldren - Set lastPointIdValue 00024 * @history 2010-06-03 Jeannie Walldren - Initialized pointers 00025 * to null. 00026 * @history 2011-03-08 Tracie Sucharski - If there is a saved ID 00027 * and there is no point in the network with that 00028 * id, do not disable "ok" button. This allows 00029 * user to use the same id from a previous point 00030 * creation if the point was never saved. 00031 * 00032 */ 00033 QnetNewPointDialog::QnetNewPointDialog(QWidget *parent) : QDialog(parent) { 00034 00035 ptIdValue = NULL; 00036 fileList = NULL; 00037 p_ptIdLabel = NULL; 00038 p_okButton = NULL; 00039 00040 p_ptIdLabel = new QLabel("Point ID:"); 00041 ptIdValue = new QLineEdit; 00042 p_ptIdLabel->setBuddy(ptIdValue); 00043 ptIdValue->setText(lastPtIdValue); 00044 ptIdValue->selectAll(); 00045 connect(ptIdValue, SIGNAL(textChanged(const QString &)), 00046 this, SLOT(enableOkButton(const QString &))); 00047 00048 QLabel *listLabel = new QLabel("Select Files:"); 00049 00050 fileList = new QListWidget; 00051 fileList->setSelectionMode(QAbstractItemView::ExtendedSelection); 00052 00053 // Create OK & Cancel buttons 00054 p_okButton = new QPushButton("OK"); 00055 // If the last point id used was never saved to network, do not set ok 00056 // button to faslse 00057 if (lastPtIdValue.isEmpty() || g_controlNetwork->ContainsPoint(lastPtIdValue)) { 00058 p_okButton->setEnabled(false); 00059 } 00060 QPushButton *cancelButton = new QPushButton("Cancel"); 00061 QHBoxLayout *buttonLayout = new QHBoxLayout; 00062 buttonLayout->addWidget(p_okButton); 00063 buttonLayout->addWidget(cancelButton); 00064 00065 connect(p_okButton, SIGNAL(clicked()), this, SLOT(accept())); 00066 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); 00067 00068 QHBoxLayout *ptIdLayout = new QHBoxLayout; 00069 ptIdLayout->addWidget(p_ptIdLabel); 00070 ptIdLayout->addWidget(ptIdValue); 00071 00072 QVBoxLayout *vLayout = new QVBoxLayout; 00073 vLayout->addLayout(ptIdLayout); 00074 vLayout->addWidget(listLabel); 00075 vLayout->addWidget(fileList); 00076 vLayout->addLayout(buttonLayout); 00077 00078 setLayout(vLayout); 00079 setWindowTitle("Create New ControlPoint"); 00080 00081 } 00082 00083 00084 /** 00085 * @internal 00086 * @history 2010-06-03 Jeannie Walldren - Removed "std::" 00087 * since "using namespace std" 00088 * @history 2010-10-29 Tracie Sucharski - Changed std::vector<std::string> 00089 * to QSringList 00090 */ 00091 void QnetNewPointDialog::SetFiles(QStringList pointFiles) { 00092 00093 int bottomMostSelectedItemIndex = 0; 00094 00095 for (int i = 0; i < g_serialNumberList->Size(); i++) { 00096 00097 // build new item... 00098 iString label = g_serialNumberList->Filename(i); 00099 QListWidgetItem *item = new QListWidgetItem(label); 00100 00101 // if this entry of the SerialNumberList is also in the pointFiles then 00102 // mark it as selected and insert after the last selected item (toward 00103 // the top of the list). Otherwise just add the item to the end of the 00104 // list 00105 if (pointFiles.contains(label)) { 00106 fileList->insertItem(bottomMostSelectedItemIndex++, item); 00107 item->setSelected(true); 00108 } 00109 else { 00110 fileList->addItem(item); 00111 } 00112 } 00113 } 00114 00115 00116 /** 00117 * 00118 * @param text 00119 * @internal 00120 * @history 2008-11-26 Jeannie Walldren - Set lastPointIdValue 00121 * to the p_ptIdValue 00122 */ 00123 void QnetNewPointDialog::enableOkButton(const QString &text) { 00124 QnetNewPointDialog::lastPtIdValue = ptIdValue->text(); 00125 p_okButton->setEnabled(!text.isEmpty()); 00126 } 00127 00128 00129 }