Changeset 5114 in ntrip for trunk/GnssCenter/inpedit/selwin.cpp


Ignore:
Timestamp:
Apr 12, 2013, 6:30:08 PM (9 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GnssCenter/inpedit/selwin.cpp

    r5000 r5114  
    2323// Constructor
    2424////////////////////////////////////////////////////////////////////////////////
    25 t_selWin::t_selWin(QWidget* parent, t_selWin::Mode mode) :
    26   QWidget(parent), _mode(mode) {
     25t_selWin::t_selWin(t_selWin::Mode mode, QWidget* parent) : QWidget(parent) {
     26
     27  _mode = mode;
    2728
    2829  QHBoxLayout* layout = new QHBoxLayout( this );
     
    3334
    3435  connect(_lineEdit, SIGNAL(textChanged(const QString &)),
    35           this, SIGNAL(fileNameChanged(const QString &)));
     36          this, SLOT(slotTextChanged()));
    3637
    3738  _button = new QPushButton("...", this);
     
    3940  layout->addWidget(_button);
    4041
    41   connect(_button, SIGNAL(clicked()), this, SLOT(chooseFile()));
     42  connect(_button, SIGNAL(clicked()), this, SLOT(slotChooseFile()));
    4243  setFocusProxy(_lineEdit);
    4344}
     
    5051//
    5152////////////////////////////////////////////////////////////////////////////////
    52 void t_selWin::setFileName(const QString& fileName) {
    53   _lineEdit->setText(fileName);
     53void t_selWin::setFileNames(const QStringList& fileNames) {
     54  _fileNames = fileNames;
     55  setLineEditText();
    5456}
    5557
    5658//
    5759////////////////////////////////////////////////////////////////////////////////
    58 QString t_selWin::fileName() const {
    59   return _lineEdit->text();
     60void 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  }
    6070}
    6171
    6272//
    6373////////////////////////////////////////////////////////////////////////////////
    64 void t_selWin::chooseFile() {
    65   QString fileName;
     74const QStringList& t_selWin::fileNames() const {
     75  return _fileNames;
     76}
     77
     78//
     79////////////////////////////////////////////////////////////////////////////////
     80void t_selWin::slotTextChanged() {
     81  _fileNames.clear();
     82  if (!_lineEdit->text().isEmpty()) {
     83    _fileNames << _lineEdit->text();
     84  }
     85  emit fileNameChanged();
     86}
     87
     88//
     89////////////////////////////////////////////////////////////////////////////////
     90void t_selWin::slotChooseFile() {
    6691  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   }
    6898  }
    6999  else if (mode() == Files) {
    70100    QStringList fileNames = QFileDialog::getOpenFileNames(this);
    71     fileName = fileNames.join(",");
     101    if (fileNames.size()) {
     102      _fileNames = fileNames;
     103      emit fileNameChanged();
     104    }
    72105  }
    73106  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    }
    75113  }
     114  setLineEditText();
     115}
    76116
    77   if (!fileName.isEmpty()) {
    78     _lineEdit->setText(fileName);
    79     emit fileNameChanged(fileName);
    80   }
    81 }
Note: See TracChangeset for help on using the changeset viewer.