diff -r 000000000000 -r 84f76a3876d7 exportoofiledialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exportoofiledialog.cpp Tue Jul 04 12:10:56 2006 +0000 @@ -0,0 +1,87 @@ +#include + +#include "exportoofiledialog.h" + +ExportOOFileDialog::ExportOOFileDialog():Q3FileDialog() +{ + init(); +} + +ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):Q3FileDialog(parent, name,modal) +{ + init(); +} + +QString ExportOOFileDialog::selectedConfig() +{ + QStringList::Iterator itpath=configPaths.begin(); + QStringList::Iterator itf=filters.begin(); + while (itf != filters.end()) + { + if (*itf==lastFilter) return *itpath; + itpath++; + itf++; + } + qWarning ("ExportOOFileDialog::selectedConfig No filter found!"); + return ""; +} + +void ExportOOFileDialog::newConfigPath(const QString &s) +{ + lastFilter=s; +} + +QString ExportOOFileDialog::selectedFile() +{ + return Q3FileDialog::selectedFile(); +} + + +void ExportOOFileDialog::addFilter(const QString &f) +{ + lastFilter=f; + filters.append (f); + Q3FileDialog::addFilter (f); +} + +void ExportOOFileDialog::init() +{ + setMode( Q3FileDialog::AnyFile ); + QDir d; + d.setPath ("/usr/share/vym/exports"); + scanExportConfigs(d); + d.setPath (d.homeDirPath()+"/.vym/exports"); + scanExportConfigs(d); + d.setPath ("exports"); + scanExportConfigs(d); + + connect ( + this,SIGNAL (filterSelected(const QString&)), + this, SLOT( newConfigPath(const QString &))); +} + +void ExportOOFileDialog::scanExportConfigs(QDir dir) +{ + // Scan existing export configurations + SimpleSettings set; + QFile f; + if (dir.exists()) + { + // Traverse files + QDir dir; + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + + 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()); + set.clear(); + set.readSettings (fi.absFilePath()); + addFilter (set.readEntry("Name") + " (*.odp)"); + } + } + } +}