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