author | insilmaril |
Fri Jan 05 11:17:33 2007 +0000 (2007-01-05) | |
changeset 419 | 3988818e8087 |
parent 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@365 | 10 |
ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const QString &caption ):QFileDialog(parent, caption) |
insilmaril@181 | 11 |
{ |
insilmaril@181 | 12 |
init(); |
insilmaril@181 | 13 |
} |
insilmaril@181 | 14 |
|
insilmaril@357 | 15 |
bool ExportOOFileDialog::foundConfig() |
insilmaril@357 | 16 |
{ |
insilmaril@357 | 17 |
return !filters.isEmpty(); |
insilmaril@357 | 18 |
} |
insilmaril@357 | 19 |
|
insilmaril@365 | 20 |
|
insilmaril@181 | 21 |
QString ExportOOFileDialog::selectedConfig() |
insilmaril@181 | 22 |
{ |
insilmaril@181 | 23 |
QStringList::Iterator itpath=configPaths.begin(); |
insilmaril@181 | 24 |
QStringList::Iterator itf=filters.begin(); |
insilmaril@181 | 25 |
while (itf != filters.end()) |
insilmaril@181 | 26 |
{ |
insilmaril@365 | 27 |
if (*itf==selectedFilter()) return *itpath; |
insilmaril@181 | 28 |
itpath++; |
insilmaril@181 | 29 |
itf++; |
insilmaril@181 | 30 |
} |
insilmaril@181 | 31 |
qWarning ("ExportOOFileDialog::selectedConfig No filter found!"); |
insilmaril@181 | 32 |
return ""; |
insilmaril@181 | 33 |
} |
insilmaril@181 | 34 |
|
insilmaril@181 | 35 |
void ExportOOFileDialog::newConfigPath(const QString &s) |
insilmaril@181 | 36 |
{ |
insilmaril@181 | 37 |
lastFilter=s; |
insilmaril@181 | 38 |
} |
insilmaril@181 | 39 |
|
insilmaril@181 | 40 |
QString ExportOOFileDialog::selectedFile() |
insilmaril@181 | 41 |
{ |
insilmaril@181 | 42 |
return QFileDialog::selectedFile(); |
insilmaril@181 | 43 |
} |
insilmaril@181 | 44 |
|
insilmaril@181 | 45 |
|
insilmaril@365 | 46 |
void ExportOOFileDialog::show() |
insilmaril@181 | 47 |
{ |
insilmaril@365 | 48 |
setFilters (filters); |
insilmaril@365 | 49 |
QFileDialog::show(); |
insilmaril@181 | 50 |
} |
insilmaril@181 | 51 |
|
insilmaril@181 | 52 |
void ExportOOFileDialog::init() |
insilmaril@181 | 53 |
{ |
insilmaril@198 | 54 |
setMode( QFileDialog::AnyFile ); |
insilmaril@181 | 55 |
QDir d; |
insilmaril@181 | 56 |
d.setPath ("/usr/share/vym/exports"); |
insilmaril@181 | 57 |
scanExportConfigs(d); |
insilmaril@196 | 58 |
d.setPath (d.homeDirPath()+"/.vym/exports"); |
insilmaril@181 | 59 |
scanExportConfigs(d); |
insilmaril@365 | 60 |
d.setPath (d.currentPath()+"/exports"); |
insilmaril@181 | 61 |
scanExportConfigs(d); |
insilmaril@181 | 62 |
|
insilmaril@181 | 63 |
connect ( |
insilmaril@181 | 64 |
this,SIGNAL (filterSelected(const QString&)), |
insilmaril@181 | 65 |
this, SLOT( newConfigPath(const QString &))); |
insilmaril@181 | 66 |
} |
insilmaril@181 | 67 |
|
insilmaril@365 | 68 |
void ExportOOFileDialog::addFilter(const QString &f) |
insilmaril@365 | 69 |
{ |
insilmaril@365 | 70 |
lastFilter=f; |
insilmaril@365 | 71 |
filters.append (f); |
insilmaril@365 | 72 |
} |
insilmaril@365 | 73 |
|
insilmaril@365 | 74 |
void ExportOOFileDialog::scanExportConfigs(QDir dir) |
insilmaril@181 | 75 |
{ |
insilmaril@181 | 76 |
// Scan existing export configurations |
insilmaril@181 | 77 |
SimpleSettings set; |
insilmaril@181 | 78 |
QFile f; |
insilmaril@365 | 79 |
if (dir.exists()) |
insilmaril@181 | 80 |
{ |
insilmaril@181 | 81 |
// Traverse files |
insilmaril@365 | 82 |
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); |
insilmaril@181 | 83 |
|
insilmaril@365 | 84 |
QFileInfoList list = dir.entryInfoList(); |
insilmaril@365 | 85 |
for (int i = 0; i < list.size(); ++i) { |
insilmaril@365 | 86 |
QFileInfo fi = list.at(i); |
insilmaril@365 | 87 |
|
insilmaril@365 | 88 |
if (fi.fileName().endsWith(".conf") ) |
insilmaril@181 | 89 |
{ |
insilmaril@365 | 90 |
configPaths.append (fi.absFilePath()); |
insilmaril@181 | 91 |
set.clear(); |
insilmaril@365 | 92 |
set.readSettings (fi.absFilePath()); |
insilmaril@365 | 93 |
addFilter (set.readEntry(QString("Name")) + " (*.odp)"); |
insilmaril@181 | 94 |
} |
insilmaril@365 | 95 |
} |
insilmaril@181 | 96 |
} |
insilmaril@181 | 97 |
} |