// Makes a list of filters from ;;-separated text. static QList<qt_mac_filter_name*> makeFiltersList(const QString &filter) { #ifdef DEBUG_FILEDIALOG_FILTERS qDebug("Q3FileDialog:%d - Got filter (%s)", __LINE__, filter.latin1()); #endif QString f(filter); if(f.isEmpty()) f = Q3FileDialog::tr("All Files (*)"); if(f.isEmpty()) return QList<qt_mac_filter_name*>(); QString sep(QLatin1String(";;")); int i = f.indexOf(sep, 0); if(i == -1) { sep = QLatin1String("\n"); if(f.indexOf(sep, 0) != -1) i = f.indexOf(sep, 0); } QList<qt_mac_filter_name*> ret; QStringList filts = f.split(sep); for (QStringList::Iterator it = filts.begin(); it != filts.end(); ++it) { qt_mac_filter_name *filter = extractFilter((*it)); #ifdef DEBUG_FILEDIALOG_FILTERS qDebug("Q3FileDialog:%d Split out filter (%d) '%s' '%s'", __LINE__, ret.count(), filter->regxp.latin1(), filter->description.latin1()); #endif ret.append(filter); } return ret; }
/** * Converts QFileDialog filter list to Win32 API filter list. */ static QString winFilter (const QString &aFilter) { QStringList filterLst; if (!aFilter.isEmpty()) { int i = aFilter.indexOf (";;", 0); QString sep (";;"); if (i == -1) { if (aFilter.indexOf ("\n", 0) != -1) { sep = "\n"; i = aFilter.indexOf (sep, 0); } } filterLst = aFilter.split (sep); } QStringList::Iterator it = filterLst.begin(); QString winfilters; for (; it != filterLst.end(); ++ it) { winfilters += *it; winfilters += QChar::Null; winfilters += extractFilter (*it); winfilters += QChar::Null; } winfilters += QChar::Null; return winfilters; }
// Makes a NUL-oriented Windows filter from a Qt filter. static QString winFilter(const QString& filter) { QStringList filterLst = makeFiltersList(filter); QStringList::Iterator it = filterLst.begin(); QString winfilters; for (; it != filterLst.end(); ++it) { winfilters += *it; winfilters += QChar::null; winfilters += extractFilter(*it); winfilters += QChar::null; } winfilters += QChar::null; return winfilters; }