~ubuntu-branches/ubuntu/oneiric/muse/oneiric

« back to all changes in this revision

Viewing changes to muse/widgets/filedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-11-17 21:43:38 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101117214338-1hvfl7oo2dsqnvrb
Tags: 1.1-0ubuntu1
* New upstream release (LP: #668631)
* Switch to dpkg-source 3.0 (quilt) format
* Switch to dh7 short form
* debian/rules:
  - added --enable-dssi and --enable-osc to conf flags for dssi support
  - added -ljackserver to LDFLAGS to fix a FTBFS because of --as-needed
* debian/control:
  - added build build dependency on liblo-dev and dssi-dev for dssi support
  - bump Standards-version to 3.9.1. No changes required.
* debian/muse.desktop, debian/muse.xpm: dropped as desktop file and icon is
  now shipped upstream.
* fix-desktop-categories.patch: fix Categories tag in upstream desktop file
* 10_es_locale_fix.dpatch: refreshed and converted to quilt as
  fix_es_locale.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
263
263
      }
264
264
 
265
265
//---------------------------------------------------------
 
266
//   getFilterExtension
 
267
//---------------------------------------------------------
 
268
 
 
269
QString getFilterExtension(const QString &filter)
 
270
{
 
271
  //
 
272
  // Return the first extension found. Must contain at least one * character.
 
273
  //
 
274
  
 
275
  int pos = filter.find('*');
 
276
  if(pos == -1)
 
277
    return QString(); 
 
278
  
 
279
  QString filt;
 
280
  int len = filter.length();
 
281
  ++pos;
 
282
  for( ; pos < len; ++pos)
 
283
  {
 
284
    QChar c = filter[pos];
 
285
    if((c == ')') || (c == ';') || (c == ',') || (c == ' '))
 
286
      break; 
 
287
    filt += filter[pos];
 
288
  }
 
289
  return filt;
 
290
}
 
291
 
 
292
//---------------------------------------------------------
266
293
//   getOpenFileName
267
294
//---------------------------------------------------------
268
295
 
269
296
QString getOpenFileName(const QString &startWith,
270
 
   const char** filters, QWidget* parent, const QString& name, bool* all)
 
297
   //const char** filters, QWidget* parent, const QString& name, bool* all)
 
298
   const QStringList& filters, QWidget* parent, const QString& name, bool* all)
271
299
      {
272
300
      QString initialSelection;
273
301
      MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, false);
294
322
//---------------------------------------------------------
295
323
 
296
324
QString getSaveFileName(const QString &startWith,
297
 
   const char** filters, QWidget* parent, const QString& name)
 
325
   //const char** filters, QWidget* parent, const QString& name)
 
326
   const QStringList& filters, QWidget* parent, const QString& name)
298
327
      {
299
328
      MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, true);
300
329
      dlg->setFilters(filters);
301
330
      dlg->setCaption(name);
302
331
      dlg->setMode(QFileDialog::AnyFile);
303
332
      QString result;
304
 
      if (dlg->exec() == QDialog::Accepted) {
305
 
            result = dlg->selectedFile();
306
 
            }
 
333
      if (dlg->exec() == QDialog::Accepted) 
 
334
        result = dlg->selectedFile();
 
335
            
 
336
      
 
337
      // Added by T356.
 
338
      if(!result.isEmpty())
 
339
      {
 
340
        QString filt = dlg->selectedFilter();
 
341
        filt = getFilterExtension(filt);
 
342
        // Do we have a valid extension?
 
343
        if(!filt.isEmpty())
 
344
        {
 
345
          // If the rightmost characters of the filename do not already contain
 
346
          //  the extension, add the extension to the filename.
 
347
          //if(result.right(filt.length()) != filt)
 
348
          if(!result.endsWith(filt))
 
349
            result += filt;
 
350
        }
 
351
        else
 
352
        {
 
353
          // No valid extension, or just * was given. Although it would be nice to allow no extension
 
354
          //  or any desired extension by commenting this section out, it's probably not a good idea to do so.
 
355
          //
 
356
          // NOTE: Most calls to this routine getSaveFileName() are followed by fileOpen(),
 
357
          //  which can tack on its own extension, but only if the *complete* extension is blank. 
 
358
          // So there is some overlap going on. Enabling this actually stops that action, 
 
359
          //  but only if there are no errors in the list of filters. fileOpen() will act as a 'catchall'.
 
360
          //
 
361
          // Force the filter list to the first one (the preferred one), and then get the filter.
 
362
          dlg->setSelectedFilter(0);
 
363
          filt = dlg->selectedFilter();
 
364
          filt = getFilterExtension(filt);
 
365
              
 
366
          // Do we have a valid extension?
 
367
          if(!filt.isEmpty())
 
368
          {
 
369
            // If the rightmost characters of the filename do not already contain
 
370
            //  the extension, add the extension to the filename.
 
371
            //if(result.right(filt.length()) != filt)
 
372
            if(!result.endsWith(filt))
 
373
              result += filt;
 
374
          }
 
375
        }
 
376
      }
 
377
      
307
378
      delete dlg;
308
379
      return result;
309
380
      }
313
384
//---------------------------------------------------------
314
385
 
315
386
QString getImageFileName(const QString& startWith,
316
 
   const char** filters, QWidget* parent, const QString& name)
 
387
   //const char** filters, QWidget* parent, const QString& name)
 
388
   const QStringList& filters, QWidget* parent, const QString& name)
317
389
      {
318
390
      QString initialSelection;
319
391
        QString* workingDirectory = new QString(QDir::currentDirPath());
444
516
//   open
445
517
//---------------------------------------------------------
446
518
 
447
 
FILE* MFile::open(const char* mode, const char** pattern,
 
519
//FILE* MFile::open(const char* mode, const char** pattern,
 
520
FILE* MFile::open(const char* mode, const QStringList& pattern,
448
521
   QWidget* parent, bool noError, bool warnIfOverwrite, const QString& caption)
449
522
      {
450
523
      QString name;