Implement appendFilter[Group], signal+slot
Change-Id: I0a195de54a8631c2218f6704ca564c0c9f06becf
This commit is contained in:
@@ -57,24 +57,6 @@ QString KDE5FilePicker::getDisplayDirectory() const { return _dialog->directoryU
|
||||
|
||||
QList<QUrl> KDE5FilePicker::getSelectedFiles() const { return _dialog->selectedUrls(); }
|
||||
|
||||
void KDE5FilePicker::appendFilter(const QString& title, const QString& filter)
|
||||
{
|
||||
QString t = title;
|
||||
QString f = filter;
|
||||
// '/' need to be escaped else they are assumed to be mime types by kfiledialog
|
||||
//see the docs
|
||||
t.replace("/", "\\/");
|
||||
|
||||
// openoffice gives us filters separated by ';' qt dialogs just want space separated
|
||||
f.replace(";", " ");
|
||||
|
||||
// make sure "*.*" is not used as "all files"
|
||||
f.replace("*.*", "*");
|
||||
|
||||
_filters << QStringLiteral("%1 (%2)").arg(t, f);
|
||||
_titleToFilters[t] = _filters.constLast();
|
||||
}
|
||||
|
||||
void KDE5FilePicker::setCurrentFilter(const QString& title)
|
||||
{
|
||||
_currentFilter = _titleToFilters.value(title);
|
||||
|
@@ -176,6 +176,9 @@ Q_SIGNALS:
|
||||
void setDisplayDirectorySignal(const OUString& rDir);
|
||||
void setValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction,
|
||||
const css::uno::Any& rValue);
|
||||
void appendFilterSignal(const OUString& rTitle, const OUString& rFilter);
|
||||
void appendFilterGroupSignal(const OUString& rTitle,
|
||||
const css::uno::Sequence<css::beans::StringPair>& rFilters);
|
||||
|
||||
private Q_SLOTS:
|
||||
void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
|
||||
@@ -184,6 +187,17 @@ private Q_SLOTS:
|
||||
{
|
||||
return setValue(nControlAction, nControlAction, rValue);
|
||||
}
|
||||
|
||||
void appendFilterSlot(const OUString& rTitle, const OUString& rFilter)
|
||||
{
|
||||
return appendFilter(rTitle, rFilter);
|
||||
}
|
||||
|
||||
void appendFilterGroupSlot(const OUString& rTitle,
|
||||
const css::uno::Sequence<css::beans::StringPair>& rFilters)
|
||||
{
|
||||
return appendFilterGroup(rTitle, rFilters);
|
||||
}
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -107,6 +107,10 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
|
||||
Qt::BlockingQueuedConnection);
|
||||
connect(this, &KDE5FilePicker::setValueSignal, this, &KDE5FilePicker::setValueSlot,
|
||||
Qt::BlockingQueuedConnection);
|
||||
connect(this, &KDE5FilePicker::appendFilterSignal, this, &KDE5FilePicker::appendFilterSlot,
|
||||
Qt::BlockingQueuedConnection);
|
||||
connect(this, &KDE5FilePicker::appendFilterGroupSignal, this,
|
||||
&KDE5FilePicker::appendFilterGroupSlot, Qt::BlockingQueuedConnection);
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
setMultiSelectionMode(false);
|
||||
@@ -183,7 +187,29 @@ uno::Sequence<OUString> SAL_CALL KDE5FilePicker::getSelectedFiles()
|
||||
return seq;
|
||||
}
|
||||
|
||||
void SAL_CALL KDE5FilePicker::appendFilter(const OUString& title, const OUString& filter) {}
|
||||
void SAL_CALL KDE5FilePicker::appendFilter(const OUString& title, const OUString& filter)
|
||||
{
|
||||
if (qApp->thread() != QThread::currentThread())
|
||||
{
|
||||
SolarMutexReleaser aReleaser;
|
||||
return Q_EMIT appendFilterSignal(title, filter);
|
||||
}
|
||||
|
||||
QString t(toQString(title));
|
||||
QString f(toQString(filter));
|
||||
// '/' need to be escaped else they are assumed to be mime types by kfiledialog
|
||||
//see the docs
|
||||
t.replace("/", "\\/");
|
||||
|
||||
// libreoffice separates by filters by ';' qt dialogs by space
|
||||
f.replace(";", " ");
|
||||
|
||||
// make sure "*.*" is not used as "all files"
|
||||
f.replace("*.*", "*");
|
||||
|
||||
_filters << QStringLiteral("%1 (%2)").arg(t, f);
|
||||
_titleToFilters[t] = _filters.constLast();
|
||||
}
|
||||
|
||||
void SAL_CALL KDE5FilePicker::setCurrentFilter(const OUString& title) {}
|
||||
|
||||
@@ -193,9 +219,15 @@ OUString SAL_CALL KDE5FilePicker::getCurrentFilter()
|
||||
return filter;
|
||||
}
|
||||
|
||||
void SAL_CALL KDE5FilePicker::appendFilterGroup(const OUString& /*rGroupTitle*/,
|
||||
void SAL_CALL KDE5FilePicker::appendFilterGroup(const OUString& rGroupTitle,
|
||||
const uno::Sequence<beans::StringPair>& filters)
|
||||
{
|
||||
if (qApp->thread() != QThread::currentThread())
|
||||
{
|
||||
SolarMutexReleaser aReleaser;
|
||||
return Q_EMIT appendFilterGroupSignal(rGroupTitle, filters);
|
||||
}
|
||||
|
||||
const sal_uInt16 length = filters.getLength();
|
||||
for (sal_uInt16 i = 0; i < length; ++i)
|
||||
{
|
||||
|
Reference in New Issue
Block a user