Back to index

scribus-ng  1.3.4.dfsg+svn20071115
csvdia.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "csvdia.h"
00008 #include "csvdia.moc"
00009 
00010 #include "scribusapi.h"
00011 
00012 extern QPixmap SCRIBUS_API loadIcon(QString nam);
00013 
00014 CsvDialog::CsvDialog() : QDialog(0, "csvdia", true, 0)
00015 {
00016        setCaption( tr("CSV Importer Options"));
00017        setIcon(loadIcon("AppIcon.png"));
00018 
00019        QBoxLayout* layout = new QVBoxLayout(this);
00020 
00021        QBoxLayout* flayout = new QHBoxLayout(0, 5, 5, "flayout");
00022        QLabel* fdlabel = new QLabel( tr("Field delimiter:"), this, "fdlabel", 0);
00023        fdlabel->setMinimumWidth(120);
00024        flayout->addWidget(fdlabel,1);
00025        fdelimCombo = new QComboBox(true, this, "fdelimCombo");
00026        QStringList fdList(",");
00027        fdList << ";";
00028        fdList << tr("(TAB)");
00029        fdelimCombo->insertStringList(fdList);
00030        fdelimCombo->setMinimumWidth(120);
00031        flayout->addWidget(fdelimCombo,5);
00032        layout->addLayout(flayout);
00033 
00034        QBoxLayout* vlayout = new QHBoxLayout(0, 5, 5, "vlayout");
00035        QLabel* vdlabel = new QLabel( tr("Value delimiter:"), this, "fdlabel", 0);
00036        vdlabel->setMinimumWidth(120);
00037        vlayout->addWidget(vdlabel,1);
00038        vdelimCombo = new QComboBox(true, this, "vdelimCombo");
00039        QStringList vdList("\"");
00040        vdList << "'" << tr("None", "delimiter");
00041        vdelimCombo->insertStringList(vdList);
00042        vdelimCombo->setMinimumWidth(120);
00043        vlayout->addWidget(vdelimCombo,5);
00044        layout->addLayout(vlayout);
00045 
00046        QBoxLayout* hlayout = new QHBoxLayout(0, 5, 5, "hlayout");
00047        headerCheck = new QCheckBox( tr("First row is a header"), this, "headerCheck");
00048        hlayout->addWidget(headerCheck);
00049        layout->addLayout(hlayout);
00050 
00051        QBoxLayout* blayout = new QHBoxLayout(0, 5, 5, "blayout");
00052        blayout->addStretch(10);
00053        okButton = new QPushButton( tr("OK"), this, "okButton");
00054        blayout->addWidget(okButton);
00055 
00056        cancelButton = new QPushButton( tr("Cancel"), this, "cancelButton");
00057        blayout->addWidget(cancelButton);
00058        layout->addLayout(blayout);
00059 
00060        connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
00061        connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
00062 }
00063 
00064 QString CsvDialog::getFDelim()
00065 {
00066        if (fdelimCombo->currentText() == tr("(TAB)"))
00067               return "\t";
00068        return fdelimCombo->currentText();
00069 }
00070 
00071 QString CsvDialog::getVDelim()
00072 {
00073        return vdelimCombo->currentText();
00074 }
00075 
00076 bool CsvDialog::hasHeader()
00077 {
00078        return headerCheck->isChecked();
00079 }
00080 
00081 bool CsvDialog::useVDelim()
00082 {
00083        return vdelimCombo->currentItem() != 2;
00084 }
00085 
00086 CsvDialog::~CsvDialog()
00087 {
00088 
00089 }