Changeset 5114 in ntrip
- Timestamp:
- Apr 12, 2013, 6:30:08 PM (12 years ago)
- Location:
- trunk/GnssCenter/inpedit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GnssCenter/inpedit/keyword.cpp
r5113 r5114 128 128 } 129 129 else if (widgetType == "selwin") { 130 t_selWin* selWin = new t_selWin(); 131 if (_origValues.size()) { 132 selWin->setFileName(_origValues[0]); 133 } 130 t_selWin::Mode mode = t_selWin::File; 131 if (_desc.value("seldir") == "true") { 132 mode = t_selWin::Directory; 133 } 134 else if (_desc.value("maxfiles").toInt() > 1) { 135 mode = t_selWin::Files; 136 } 137 t_selWin* selWin = new t_selWin(mode); 138 selWin->setFileNames(_origValues); 134 139 _widget = selWin; 135 140 } … … 194 199 else if (widgetType == "selwin") { 195 200 t_selWin* selWin = static_cast<t_selWin*>(_widget); 201 values << selWin->fileNames(); 196 202 } 197 203 else if (widgetType == "spinbox") { -
trunk/GnssCenter/inpedit/selwin.cpp
r5000 r5114 23 23 // Constructor 24 24 //////////////////////////////////////////////////////////////////////////////// 25 t_selWin::t_selWin(QWidget* parent, t_selWin::Mode mode) : 26 QWidget(parent), _mode(mode) { 25 t_selWin::t_selWin(t_selWin::Mode mode, QWidget* parent) : QWidget(parent) { 26 27 _mode = mode; 27 28 28 29 QHBoxLayout* layout = new QHBoxLayout( this ); … … 33 34 34 35 connect(_lineEdit, SIGNAL(textChanged(const QString &)), 35 this, S IGNAL(fileNameChanged(const QString &)));36 this, SLOT(slotTextChanged())); 36 37 37 38 _button = new QPushButton("...", this); … … 39 40 layout->addWidget(_button); 40 41 41 connect(_button, SIGNAL(clicked()), this, SLOT( chooseFile()));42 connect(_button, SIGNAL(clicked()), this, SLOT(slotChooseFile())); 42 43 setFocusProxy(_lineEdit); 43 44 } … … 50 51 // 51 52 //////////////////////////////////////////////////////////////////////////////// 52 void t_selWin::setFileName(const QString& fileName) { 53 _lineEdit->setText(fileName); 53 void t_selWin::setFileNames(const QStringList& fileNames) { 54 _fileNames = fileNames; 55 setLineEditText(); 54 56 } 55 57 56 58 // 57 59 //////////////////////////////////////////////////////////////////////////////// 58 QString t_selWin::fileName() const { 59 return _lineEdit->text(); 60 void t_selWin::setLineEditText() { 61 if (_fileNames.size() == 0) { 62 _lineEdit->setText(""); 63 } 64 else if (_fileNames.size() == 1) { 65 _lineEdit->setText(_fileNames[0]); 66 } 67 else if (_fileNames.size() > 1) { 68 _lineEdit->setText(QString("SELECTED (%1 FILES)").arg(_fileNames.size())); 69 } 60 70 } 61 71 62 72 // 63 73 //////////////////////////////////////////////////////////////////////////////// 64 void t_selWin::chooseFile() { 65 QString fileName; 74 const QStringList& t_selWin::fileNames() const { 75 return _fileNames; 76 } 77 78 // 79 //////////////////////////////////////////////////////////////////////////////// 80 void t_selWin::slotTextChanged() { 81 _fileNames.clear(); 82 if (!_lineEdit->text().isEmpty()) { 83 _fileNames << _lineEdit->text(); 84 } 85 emit fileNameChanged(); 86 } 87 88 // 89 //////////////////////////////////////////////////////////////////////////////// 90 void t_selWin::slotChooseFile() { 66 91 if (mode() == File) { 67 fileName = QFileDialog::getOpenFileName(this); 92 QString fileName = QFileDialog::getOpenFileName(this); 93 if (!fileName.isEmpty()) { 94 _fileNames.clear(); 95 _fileNames << fileName; 96 emit fileNameChanged(); 97 } 68 98 } 69 99 else if (mode() == Files) { 70 100 QStringList fileNames = QFileDialog::getOpenFileNames(this); 71 fileName = fileNames.join(","); 101 if (fileNames.size()) { 102 _fileNames = fileNames; 103 emit fileNameChanged(); 104 } 72 105 } 73 106 else { 74 fileName = QFileDialog::getExistingDirectory(this); 107 QString dirName = QFileDialog::getExistingDirectory(this); 108 if (!dirName.isEmpty()) { 109 _fileNames.clear(); 110 _fileNames << dirName; 111 emit fileNameChanged(); 112 } 75 113 } 114 setLineEditText(); 115 } 76 116 77 if (!fileName.isEmpty()) {78 _lineEdit->setText(fileName);79 emit fileNameChanged(fileName);80 }81 } -
trunk/GnssCenter/inpedit/selwin.h
r5000 r5114 7 7 8 8 class t_selWin : public QWidget { 9 Q_OBJECT 10 11 Q_ENUMS( Mode ) 12 Q_PROPERTY( Mode mode READ mode WRITE setMode ) 13 Q_PROPERTY( QString fileName READ fileName WRITE setFileName ) 9 Q_OBJECT 14 10 15 11 public: 16 12 enum Mode {File, Files, Directory}; 17 13 18 t_selWin( QWidget* parent = 0, t_selWin::Mode mode = File);14 t_selWin(t_selWin::Mode mode, QWidget* parent = 0); 19 15 ~t_selWin(); 20 16 21 QString fileName() const; 22 Mode mode() const {return _mode;} 23 24 public slots: 25 void setFileName(const QString& fileName); 26 void setMode(Mode mode) {_mode = mode;} 17 const QStringList& fileNames() const; 18 Mode mode() const {return _mode;} 19 void setFileNames(const QStringList& fileNames); 27 20 28 21 signals: 29 void fileNameChanged( const QString&);22 void fileNameChanged(); 30 23 31 24 private slots: 32 void chooseFile(); 25 void slotTextChanged(); 26 void slotChooseFile(); 33 27 34 28 private: 29 void setLineEditText(); 35 30 QLineEdit* _lineEdit; 36 31 QPushButton* _button; 37 32 Mode _mode; 33 QStringList _fileNames; 38 34 }; 39 35
Note:
See TracChangeset
for help on using the changeset viewer.