author | insilmaril |
Mon May 15 07:34:54 2006 +0000 (2006-05-15) | |
changeset 330 | d39c67b49cbd |
parent 196 | a9493dcaa306 |
child 357 | 64819498efbf |
permissions | -rw-r--r-- |
insilmaril@181 | 1 |
#include <iostream> |
insilmaril@181 | 2 |
|
insilmaril@181 | 3 |
#include "exportoofiledialog.h" |
insilmaril@181 | 4 |
|
insilmaril@181 | 5 |
ExportOOFileDialog::ExportOOFileDialog():QFileDialog() |
insilmaril@181 | 6 |
{ |
insilmaril@181 | 7 |
init(); |
insilmaril@181 | 8 |
} |
insilmaril@181 | 9 |
|
insilmaril@181 | 10 |
ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):QFileDialog(parent, name,modal) |
insilmaril@181 | 11 |
{ |
insilmaril@181 | 12 |
init(); |
insilmaril@181 | 13 |
} |
insilmaril@181 | 14 |
|
insilmaril@181 | 15 |
QString ExportOOFileDialog::selectedConfig() |
insilmaril@181 | 16 |
{ |
insilmaril@181 | 17 |
QStringList::Iterator itpath=configPaths.begin(); |
insilmaril@181 | 18 |
QStringList::Iterator itf=filters.begin(); |
insilmaril@181 | 19 |
while (itf != filters.end()) |
insilmaril@181 | 20 |
{ |
insilmaril@181 | 21 |
if (*itf==lastFilter) return *itpath; |
insilmaril@181 | 22 |
itpath++; |
insilmaril@181 | 23 |
itf++; |
insilmaril@181 | 24 |
} |
insilmaril@181 | 25 |
qWarning ("ExportOOFileDialog::selectedConfig No filter found!"); |
insilmaril@181 | 26 |
return ""; |
insilmaril@181 | 27 |
} |
insilmaril@181 | 28 |
|
insilmaril@181 | 29 |
void ExportOOFileDialog::newConfigPath(const QString &s) |
insilmaril@181 | 30 |
{ |
insilmaril@181 | 31 |
lastFilter=s; |
insilmaril@181 | 32 |
} |
insilmaril@181 | 33 |
|
insilmaril@181 | 34 |
QString ExportOOFileDialog::selectedFile() |
insilmaril@181 | 35 |
{ |
insilmaril@181 | 36 |
return QFileDialog::selectedFile(); |
insilmaril@181 | 37 |
} |
insilmaril@181 | 38 |
|
insilmaril@181 | 39 |
|
insilmaril@181 | 40 |
void ExportOOFileDialog::addFilter(const QString &f) |
insilmaril@181 | 41 |
{ |
insilmaril@181 | 42 |
lastFilter=f; |
insilmaril@181 | 43 |
filters.append (f); |
insilmaril@181 | 44 |
QFileDialog::addFilter (f); |
insilmaril@181 | 45 |
} |
insilmaril@181 | 46 |
|
insilmaril@181 | 47 |
void ExportOOFileDialog::init() |
insilmaril@181 | 48 |
{ |
insilmaril@198 | 49 |
setMode( QFileDialog::AnyFile ); |
insilmaril@181 | 50 |
QDir d; |
insilmaril@181 | 51 |
d.setPath ("/usr/share/vym/exports"); |
insilmaril@181 | 52 |
scanExportConfigs(d); |
insilmaril@196 | 53 |
d.setPath (d.homeDirPath()+"/.vym/exports"); |
insilmaril@181 | 54 |
scanExportConfigs(d); |
insilmaril@181 | 55 |
d.setPath ("exports"); |
insilmaril@181 | 56 |
scanExportConfigs(d); |
insilmaril@181 | 57 |
|
insilmaril@181 | 58 |
connect ( |
insilmaril@181 | 59 |
this,SIGNAL (filterSelected(const QString&)), |
insilmaril@181 | 60 |
this, SLOT( newConfigPath(const QString &))); |
insilmaril@181 | 61 |
} |
insilmaril@181 | 62 |
|
insilmaril@181 | 63 |
void ExportOOFileDialog::scanExportConfigs(QDir d) |
insilmaril@181 | 64 |
{ |
insilmaril@181 | 65 |
// Scan existing export configurations |
insilmaril@181 | 66 |
SimpleSettings set; |
insilmaril@181 | 67 |
QFile f; |
insilmaril@181 | 68 |
if (d.exists()) |
insilmaril@181 | 69 |
{ |
insilmaril@181 | 70 |
// Traverse files |
insilmaril@181 | 71 |
d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); |
insilmaril@181 | 72 |
const QFileInfoList *filelist = d.entryInfoList(); |
insilmaril@181 | 73 |
QFileInfoListIterator itfile( *filelist ); |
insilmaril@181 | 74 |
QFileInfo *fi; |
insilmaril@181 | 75 |
|
insilmaril@181 | 76 |
while ( (fi = itfile.current()) != 0 ) |
insilmaril@181 | 77 |
{ |
insilmaril@181 | 78 |
if (fi->fileName().endsWith(".conf") ) |
insilmaril@181 | 79 |
{ |
insilmaril@181 | 80 |
configPaths.append (fi->absFilePath()); |
insilmaril@181 | 81 |
set.clear(); |
insilmaril@181 | 82 |
set.readSettings (fi->absFilePath()); |
insilmaril@181 | 83 |
addFilter (set.readEntry("Name") + " (*.odp)"); |
insilmaril@181 | 84 |
} |
insilmaril@181 | 85 |
++itfile; |
insilmaril@181 | 86 |
} |
insilmaril@181 | 87 |
} |
insilmaril@181 | 88 |
} |