示例#1
0
mainWindow::mainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::mainWindow)
{
//#ifndef WIN32
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
//#endif
    ui->setupUi(this);
    setupDataBase();
    setupTable();
    setupComboBox();


    ui->mainToolBar->addAction(ui->actionAjouter_console);
    ui->mainToolBar->addAction(ui->actionEditer_ligne);
    ui->mainToolBar->addAction(ui->actionSupprimer_ligne);

    connect(ui->buttonAdd, SIGNAL(clicked()), this, SLOT(addGame()));
    connect(ui->actionAjouter_console, SIGNAL(triggered()), this, SLOT(addConsole()));
    connect(ui->actionSupprimer_ligne, SIGNAL(triggered()), this, SLOT(deleteGame()));
    connect(ui->actionEditer_ligne, SIGNAL(triggered()), this, SLOT(editGame()));
    connect(ui->actionExporter_en_csv, SIGNAL(triggered()), this, SLOT(exportCSV()));
    connect(ui->actionImporter_un_CSV, SIGNAL(triggered()), this, SLOT(importCSV()));
}
connectionListDialog::connectionListDialog(csv_connection * conn, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::connectionListDialog)
{
    ui->setupUi(this);

    this->conn = conn;

    ui->spinBox->setRange(0, INT_MAX); // set max from the component
    ui->spinBox->setValue(conn->getNumRows());

    connect(ui->spinBox,SIGNAL(valueChanged(int)), this, SLOT(updateValSize(int)));

    this->vModel = new csv_connectionModel();
    this->vModel->setConnection(conn);
    this->ui->tableView->setModel(this->vModel);
    QHeaderView * header = this->ui->tableView->horizontalHeader();
    header->setStretchLastSection(true);
    //header->setResizeMode(0, QHeaderView::Fixed);
    header->resizeSection(0, 80);
    header->resizeSection(1, 80);

    // hide import button if is a pythonscript
    if (this->conn->generator != NULL) {
        this->ui->import_csv->setVisible(false);
        this->ui->tableView->setMinimumWidth(240);
        this->ui->spinBox->setEnabled(false);
    }

    connect(this->ui->import_csv,SIGNAL(clicked()), this, SLOT(importCSV()));
    connect(this->vModel,SIGNAL(setSpinBoxVal(int)), ui->spinBox, SLOT(setValue(int)));
}
void CSVImportExportPluginInterface::exec()
{
    switch (mImportExportAction) {
    case Import:
        importCSV();
        break;
    case Export:
        exportCSV();
        break;
    }
}
示例#4
0
ImpExpGroup::ImpExpGroup(QWidget *parent): 
QGroupBox(tr("Import/export"), parent),
importButton_(tr("Import csv"), this),
exportButton_(tr("Export csv"), this) {

	QHBoxLayout* layout = new QHBoxLayout(this);
	layout->addWidget(&importButton_);
	layout->addWidget(&exportButton_);

	connect(&importButton_, SIGNAL(clicked(bool)),
		this, SIGNAL(importCSV()), Qt::UniqueConnection);
	connect(&exportButton_, SIGNAL(clicked(bool)),
		this, SIGNAL(exportCSV()), Qt::UniqueConnection);
}