1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
#include "export.h"
#include "ui_export.h"
#include <QFileDialog>
#include <QMessageBox>
#include "configtreetext.h"
Export::Export(QString filename, int mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::Export),
path(filename)
{
ui->setupUi(this);
#if defined(_WIN32) && defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP) // Workaround render bug
QString style = "QComboBox QAbstractItemView { border: 1px solid gray }";
ui->comboBoxConfig->setStyleSheet(style);
ui->comboBoxMode->setStyleSheet(style);
#else
setWindowTitle(tr("Export"));
#endif
for(int i=0;i<Export::NB_EXPORT_MODE;i++) {
ui->comboBoxMode->addItem(name(i),i);
if(i==mode)
ui->comboBoxMode->setCurrentIndex(ui->comboBoxMode->count()-1);
}
ConfigTreeText::fillComboBox(ui->comboBoxConfig);
}
Export::~Export()
{
delete ui;
}
void Export::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
int Export::getExportMode() {
return ui->comboBoxMode->itemData(ui->comboBoxMode->currentIndex()).toInt();
}
int Export::getExportConfig() {
if(ui->comboBoxConfig->isEnabled())
return ui->comboBoxConfig->itemData(ui->comboBoxConfig->currentIndex()).toInt();
else
return 0;
}
QString Export::getFileName() {
return path;
}
QIODevice::OpenMode Export::getOpenMode() {
if(ui->appendToFile->isChecked())
return QIODevice::Append;
else
return QIODevice::WriteOnly;
}
bool Export::isAdvancedChecked() {
return ui->checkBoxAdvanced->isChecked();
}
QString Export::extension(int mode) {
switch(mode) {
default:
case TEXT: return "txt";
break;
case HTML: return "html";
break;
case GRAPH: return "svg";
break;
case XML:
case PBCORE:
case PBCORE2:
case MPEG7_Strict:
case MPEG7_Relaxed:
case MPEG7_Extended:
case NISO_Z39_87:
case FIMS_1_1:
case FIMS_1_2:
case FIMS_1_3:
case EBUCORE_1_5:
case EBUCORE_1_6:
case EBUCORE_1_8_ps:
case EBUCORE_1_8_sp: return "xml";
break;
case JSON:
case EBUCORE_1_8_ps_JSON:
case EBUCORE_1_8_sp_JSON: return "json";
break;
}
}
QString Export::extensionName(int mode) {
switch(mode) {
default:
case TEXT: return tr("Text");
break;
case HTML: return "HTML";
break;
case GRAPH: return tr("Graph");
break;
case XML:
case PBCORE:
case PBCORE2:
case MPEG7_Strict:
case MPEG7_Relaxed:
case MPEG7_Extended:
case NISO_Z39_87:
case FIMS_1_1:
case FIMS_1_2:
case FIMS_1_3:
case EBUCORE_1_5:
case EBUCORE_1_6:
case EBUCORE_1_8_ps:
case EBUCORE_1_8_sp: return "XML";
break;
case JSON:
case EBUCORE_1_8_ps_JSON:
case EBUCORE_1_8_sp_JSON: return "JSON";
break;
}
}
QString Export::name(int mode) {
switch(mode) {
default:
case TEXT: return tr("Text");
break;
case HTML: return tr("HTML");
break;
case XML: return tr("XML");
break;
case JSON: return tr("JSON");
break;
case GRAPH: return tr("Graph");
break;
case PBCORE: return tr("PBCore");
break;
case PBCORE2: return tr("PBCore 2");
break;
case MPEG7_Strict: return tr("MPEG-7 (strict)");
break;
case MPEG7_Relaxed: return tr("MPEG-7 (relaxed)");
break;
case MPEG7_Extended: return tr("MPEG-7 (extended)");
break;
case EBUCORE_1_5: return tr("EBUCore 1.5");
break;
case EBUCORE_1_6: return tr("EBUCore 1.6");
break;
case EBUCORE_1_8_ps: return tr("EBUCore 1.8 parameter then segment");
break;
case EBUCORE_1_8_sp: return tr("EBUCore 1.8 segment then parameter");
break;
case EBUCORE_1_8_ps_JSON: return tr("EBUCore 1.8 parameter then segment (JSON output)");
break;
case EBUCORE_1_8_sp_JSON: return tr("EBUCore 1.8 segment then parameter (JSON output)");
break;
case FIMS_1_1: return tr("FIMS 1.1");
break;
case FIMS_1_2: return tr("FIMS 1.2");
break;
case FIMS_1_3: return tr("FIMS 1.3");
break;
case NISO_Z39_87: return tr("NISO Z39.87");
break;
}
}
void Export::on_comboBoxMode_currentIndexChanged(int index)
{
QStringList filename = path.split(".");
filename[filename.size()-1] = extension(index);
path = filename.join(".");
switch(index) {
default:
case TEXT:
ui->comboBoxConfig->setDisabled(ui->checkBoxAdvanced->isChecked());
ui->checkBoxAdvanced->setEnabled(true);
break;
case XML:
case JSON:
case GRAPH:
case PBCORE:
case PBCORE2:
case MPEG7_Strict:
case MPEG7_Relaxed:
case MPEG7_Extended:
case EBUCORE_1_5:
case EBUCORE_1_6:
case EBUCORE_1_8_ps:
case EBUCORE_1_8_sp:
case EBUCORE_1_8_ps_JSON:
case EBUCORE_1_8_sp_JSON:
case FIMS_1_1:
case FIMS_1_2:
case FIMS_1_3:
case NISO_Z39_87:
ui->comboBoxConfig->setEnabled(false);
ui->checkBoxAdvanced->setEnabled(false);
break;
case HTML:
ui->comboBoxConfig->setEnabled(false);
ui->checkBoxAdvanced->setEnabled(true);
break;
}
}
void Export::on_checkBoxAdvanced_toggled(bool checked)
{
ui->comboBoxConfig->setEnabled( (!checked) && (ui->comboBoxMode->itemData(ui->comboBoxMode->currentIndex()).toInt()==TEXT) );
}
void Export::on_buttonBox_accepted()
{
path = QFileDialog::getSaveFileName(this,tr("Save File"),QDir(path).absolutePath(), QString(tr("%1 files (*.%2)")).arg(extensionName(getExportMode()), extension(getExportMode())));
}
|