diff -r 64819498efbf -r 88d558ce079d exportoofiledialog.cpp --- a/exportoofiledialog.cpp Thu Jul 13 08:40:58 2006 +0000 +++ b/exportoofiledialog.cpp Tue Sep 04 13:53:33 2007 +0000 @@ -7,7 +7,7 @@ init(); } -ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):QFileDialog(parent, name,modal) +ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const QString &caption ):QFileDialog(parent, caption) { init(); } @@ -17,13 +17,14 @@ return !filters.isEmpty(); } + QString ExportOOFileDialog::selectedConfig() { QStringList::Iterator itpath=configPaths.begin(); QStringList::Iterator itf=filters.begin(); while (itf != filters.end()) { - if (*itf==lastFilter) return *itpath; + if (*itf==selectedFilter()) return *itpath; itpath++; itf++; } @@ -42,11 +43,10 @@ } -void ExportOOFileDialog::addFilter(const QString &f) +void ExportOOFileDialog::show() { - lastFilter=f; - filters.append (f); - QFileDialog::addFilter (f); + setFilters (filters); + QFileDialog::show(); } void ExportOOFileDialog::init() @@ -57,7 +57,7 @@ scanExportConfigs(d); d.setPath (d.homeDirPath()+"/.vym/exports"); scanExportConfigs(d); - d.setPath ("exports"); + d.setPath (d.currentPath()+"/exports"); scanExportConfigs(d); connect ( @@ -65,29 +65,33 @@ this, SLOT( newConfigPath(const QString &))); } -void ExportOOFileDialog::scanExportConfigs(QDir d) +void ExportOOFileDialog::addFilter(const QString &f) +{ + lastFilter=f; + filters.append (f); +} + +void ExportOOFileDialog::scanExportConfigs(QDir dir) { // Scan existing export configurations SimpleSettings set; QFile f; - if (d.exists()) + if (dir.exists()) { // Traverse files - d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *filelist = d.entryInfoList(); - QFileInfoListIterator itfile( *filelist ); - QFileInfo *fi; + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - while ( (fi = itfile.current()) != 0 ) - { - if (fi->fileName().endsWith(".conf") ) + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) { + QFileInfo fi = list.at(i); + + if (fi.fileName().endsWith(".conf") ) { - configPaths.append (fi->absFilePath()); + configPaths.append (fi.absFilePath()); set.clear(); - set.readSettings (fi->absFilePath()); - addFilter (set.readEntry("Name") + " (*.odp)"); + set.readSettings (fi.absFilePath()); + addFilter (set.readEntry(QString("Name")) + " (*.odp)"); } - ++itfile; - } + } } }