1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/exportoofiledialog.cpp Tue Jul 04 12:10:56 2006 +0000
1.3 @@ -0,0 +1,87 @@
1.4 +#include <iostream>
1.5 +
1.6 +#include "exportoofiledialog.h"
1.7 +
1.8 +ExportOOFileDialog::ExportOOFileDialog():Q3FileDialog()
1.9 +{
1.10 + init();
1.11 +}
1.12 +
1.13 +ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):Q3FileDialog(parent, name,modal)
1.14 +{
1.15 + init();
1.16 +}
1.17 +
1.18 +QString ExportOOFileDialog::selectedConfig()
1.19 +{
1.20 + QStringList::Iterator itpath=configPaths.begin();
1.21 + QStringList::Iterator itf=filters.begin();
1.22 + while (itf != filters.end())
1.23 + {
1.24 + if (*itf==lastFilter) return *itpath;
1.25 + itpath++;
1.26 + itf++;
1.27 + }
1.28 + qWarning ("ExportOOFileDialog::selectedConfig No filter found!");
1.29 + return "";
1.30 +}
1.31 +
1.32 +void ExportOOFileDialog::newConfigPath(const QString &s)
1.33 +{
1.34 + lastFilter=s;
1.35 +}
1.36 +
1.37 +QString ExportOOFileDialog::selectedFile()
1.38 +{
1.39 + return Q3FileDialog::selectedFile();
1.40 +}
1.41 +
1.42 +
1.43 +void ExportOOFileDialog::addFilter(const QString &f)
1.44 +{
1.45 + lastFilter=f;
1.46 + filters.append (f);
1.47 + Q3FileDialog::addFilter (f);
1.48 +}
1.49 +
1.50 +void ExportOOFileDialog::init()
1.51 +{
1.52 + setMode( Q3FileDialog::AnyFile );
1.53 + QDir d;
1.54 + d.setPath ("/usr/share/vym/exports");
1.55 + scanExportConfigs(d);
1.56 + d.setPath (d.homeDirPath()+"/.vym/exports");
1.57 + scanExportConfigs(d);
1.58 + d.setPath ("exports");
1.59 + scanExportConfigs(d);
1.60 +
1.61 + connect (
1.62 + this,SIGNAL (filterSelected(const QString&)),
1.63 + this, SLOT( newConfigPath(const QString &)));
1.64 +}
1.65 +
1.66 +void ExportOOFileDialog::scanExportConfigs(QDir dir)
1.67 +{
1.68 + // Scan existing export configurations
1.69 + SimpleSettings set;
1.70 + QFile f;
1.71 + if (dir.exists())
1.72 + {
1.73 + // Traverse files
1.74 + QDir dir;
1.75 + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
1.76 +
1.77 + QFileInfoList list = dir.entryInfoList();
1.78 + for (int i = 0; i < list.size(); ++i) {
1.79 + QFileInfo fi = list.at(i);
1.80 +
1.81 + if (fi.fileName().endsWith(".conf") )
1.82 + {
1.83 + configPaths.append (fi.absFilePath());
1.84 + set.clear();
1.85 + set.readSettings (fi.absFilePath());
1.86 + addFilter (set.readEntry("Name") + " (*.odp)");
1.87 + }
1.88 + }
1.89 + }
1.90 +}