57 #include <QStringList> 60 #include <QFileDialog> 76 void addRecentFile(QString _file,
DataType _type);
85 void rememberRecentItem(
const QString &propName,
const QString &itemName,
const int RECENT_ITEMS_MAX_SIZE = 10);
91 QStringList getRecentItems(
const QString &propName);
98 QString getMostRecentItem(
const QString &propName);
107 inline static void updateComboBox(QComboBox *cb,
const QString &value,
const char *propName) {
110 if (value.length() > 0)
111 rememberRecentItem(QString::fromUtf8(propName), value);
112 const QStringList content = getRecentItems(QString::fromUtf8(propName));
113 cb->insertItems(0, content);
115 cb->setEditText(value);
132 inline static QString obtainPathName(QComboBox *cb,
const char *title,
const char *filters,
133 const char *propName, DialogType dialog_type = DT_OPEN) {
135 switch (dialog_type) {
137 result = QFileDialog::getOpenFileName(0, QObject::tr(title), cb->currentText(), QObject::tr(filters));
140 result = QFileDialog::getSaveFileName(0, QObject::tr(title), cb->currentText(), QObject::tr(filters));
143 result = QFileDialog::getExistingDirectory(0, QObject::tr(title), cb->currentText());
146 throw std::logic_error(
"Unknown value for dialog_type.");
149 if (result.length() > 0)
150 updateComboBox(cb, result, propName);