Esempio n. 1
0
BOOL COpenDlg::OnInitDialog()
{
	CStandAloneDialog::OnInitDialog();

	CRegDWORD lastRadioButton(L"Software\\TortoiseGitMerge\\OpenRadio", IDC_MERGERADIO);
	if (((DWORD)lastRadioButton != IDC_MERGERADIO)&&((DWORD)lastRadioButton != IDC_APPLYRADIO))
		lastRadioButton = IDC_MERGERADIO;
	GroupRadio((DWORD)lastRadioButton);
	CheckRadioButton(IDC_MERGERADIO, IDC_APPLYRADIO, (DWORD)lastRadioButton);

	// turn on auto completion for the edit controls
	AutoCompleteOn(IDC_BASEFILEEDIT);
	AutoCompleteOn(IDC_THEIRFILEEDIT);
	AutoCompleteOn(IDC_YOURFILEEDIT);
	AutoCompleteOn(IDC_DIFFFILEEDIT);
	AutoCompleteOn(IDC_DIRECTORYEDIT);

	m_cFormat = RegisterClipboardFormat(L"TGIT_UNIFIEDDIFF");
	m_nextViewer = SetClipboardViewer();

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 2
0
void COpenDlg::OnOK()
{
	UpdateData(TRUE);

	bool bUDiffOnClipboard = false;
	if (OpenClipboard())
	{
		UINT enumFormat = 0;
		do
		{
			if (enumFormat == m_cFormat)
			{
				bUDiffOnClipboard = true;
			}
		} while((enumFormat = EnumClipboardFormats(enumFormat))!=0);
		CloseClipboard();
	}

	if (GetDlgItem(IDC_BASEFILEEDIT)->IsWindowEnabled())
	{
		m_sUnifiedDiffFile.Empty();
		m_sPatchDirectory.Empty();
	}
	else
	{
		m_sBaseFile.Empty();
		m_sYourFile.Empty();
		m_sTheirFile.Empty();
	}
	UpdateData(FALSE);
	CString sFile;
	if (!m_sUnifiedDiffFile.IsEmpty())
		if (!PathFileExists(m_sUnifiedDiffFile))
			sFile = m_sUnifiedDiffFile;
	if (!m_sPatchDirectory.IsEmpty())
		if (!PathFileExists(m_sPatchDirectory))
			sFile = m_sPatchDirectory;
	if (!m_sBaseFile.IsEmpty())
		if (!PathFileExists(m_sBaseFile))
			sFile = m_sBaseFile;
	if (!m_sYourFile.IsEmpty())
		if (!PathFileExists(m_sYourFile))
			sFile = m_sYourFile;
	if (!m_sTheirFile.IsEmpty())
		if (!PathFileExists(m_sTheirFile))
			sFile = m_sTheirFile;

	if (bUDiffOnClipboard && m_bFromClipboard)
	{
		if (OpenClipboard())
		{
			HGLOBAL hglb = GetClipboardData(m_cFormat);
			LPCSTR lpstr = (LPCSTR)GlobalLock(hglb);

			DWORD len = GetTempPath(0, nullptr);
			auto path = std::make_unique<TCHAR[]>(len + 1);
			auto tempF = std::make_unique<TCHAR[]>(len + 100);
			GetTempPath (len+1, path.get());
			GetTempFileName(path.get(), L"tsm", 0, tempF.get());
			CString sTempFile = CString(tempF.get());

			FILE * outFile;
			size_t patchlen = strlen(lpstr);
			_wfopen_s(&outFile, sTempFile, L"wb");
			if(outFile)
			{
				size_t size = fwrite(lpstr, sizeof(char), patchlen, outFile);
				if (size < patchlen)
					bUDiffOnClipboard = false;
				else
				{
					m_sUnifiedDiffFile = sTempFile;
					UpdateData(FALSE);
					sFile.Empty();
				}
				fclose(outFile);
			}
			GlobalUnlock(hglb);
			CloseClipboard();
		}

	}

	if (!sFile.IsEmpty())
	{
		CString sErr;
		sErr.Format(IDS_ERR_PATCH_INVALIDPATCHFILE, (LPCTSTR)sFile);
		MessageBox(sErr, nullptr, MB_ICONERROR);
		return;
	}
	CRegDWORD lastRadioButton(L"Software\\TortoiseGitMerge\\OpenRadio", IDC_MERGERADIO);
	lastRadioButton = GetCheckedRadioButton(IDC_MERGERADIO, IDC_APPLYRADIO);
	CStandAloneDialog::OnOK();
}
Esempio n. 3
0
void AlterTable::on_actionAgregar_Columna_triggered() {
    QDialog dialog(this);
    dialog.setWindowTitle("Agregar");
    QLabel messageLabel("Nombre de Columna:", &dialog);
    QLineEdit columnNameLineEdit(&dialog);
    QLabel typeLabel("Tipo:");
    QComboBox typeComboBox(&dialog);
    typeComboBox.addItems(QStringList()
                          << "TINYINT"
                         << "SMALLINT"
                         << "MEDIUMINT"
                         << "INT"
                         << "BIGINT"
                         << "BIT"
                         << "FLOAT"
                         << "DOUBLE"
                         << "DECIMAL"
                         << "CHAR"
                         << "VARCHAR"
                         << "TINYTEXT"
                         << "TEXT"
                         << "MEDIUMTEXT"
                         << "LONGTEXT"
                         << "BINARY"
                         << "VARBINARY"
                         << "TINYBLOB"
                         << "BLOB"
                         << "MEDIUMBLOB"
                         << "LONGBLOB"
                         << "DATE"
                         << "TIME"
                         << "YEAR"
                         << "DATETIME"
                         << "TIMESTAMP"
                         << "POINT"
                         << "LINESTRING"
                         << "POLYGON"
                         << "GEOMETRY"
                         << "MULTIPOINT"
                         << "MULTILINESTRING"
                         << "MULTIPOLYGON"
                         << "GEOMETRYCOLLECTION"
                         << "ENUM"
                         << "SET");
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(&messageLabel);
    layout->addWidget(&columnNameLineEdit);
    layout->addWidget(&typeLabel);
    layout->addWidget(&typeComboBox);
    QPushButton addPushButton("Agregar", &dialog);
    QPushButton cancelPushButton("Cancelar", &dialog);
    connect(&addPushButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
    connect(&cancelPushButton, SIGNAL(clicked()), &dialog, SLOT(reject()));
    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(&addPushButton);
    buttonsLayout->addWidget(&cancelPushButton);
    layout->addLayout(buttonsLayout);
    dialog.setLayout(layout);
    if (dialog.exec() == QDialog::Rejected) { return; }
    int lenght = 0;
    if (typeComboBox.currentText() == "VARCHAR" ||
        typeComboBox.currentText() == "VARBINARY") {
        QInputDialog inDialog(&dialog);
        inDialog.setWindowTitle("Longitud");
        inDialog.setLabelText("Longitud:");
        inDialog.setInputMode(QInputDialog::IntInput);
        if (inDialog.exec() == QInputDialog::Rejected) { return; }
        lenght = inDialog.intValue();
    }
    QDialog configurationDialog(&dialog);
    configurationDialog.setWindowTitle("Configuración");
    QRadioButton afterOfRadioButton("Despues de", &configurationDialog);
    QRadioButton lastRadioButton("Al Final", &configurationDialog);
    lastRadioButton.setChecked(true);
    QVBoxLayout *layoutConf = new QVBoxLayout;
    QPushButton acceptPushButton("Aceptar", &configurationDialog);
    QPushButton cancelConfPushButton("Cancelar", &configurationDialog);
    connect(&acceptPushButton, SIGNAL(clicked()), &configurationDialog,
            SLOT(accept()));
    connect(&cancelConfPushButton, SIGNAL(clicked()), &configurationDialog,
            SLOT(reject()));
    layoutConf->addWidget(&afterOfRadioButton);
    layoutConf->addWidget(&lastRadioButton);
    QHBoxLayout *buttonsConfLayout = new QHBoxLayout;
    buttonsConfLayout->addWidget(&acceptPushButton);
    buttonsConfLayout->addWidget(&cancelConfPushButton);
    layoutConf->addLayout(buttonsConfLayout);
    configurationDialog.setLayout(layoutConf);
    if (configurationDialog.exec() == QDialog::Rejected) { return; }
    QString afterOfString = QString();
    if (afterOfRadioButton.isChecked()) {
        QInputDialog inDialog(&configurationDialog);
        inDialog.setWindowTitle("Referencia");
        inDialog.setLabelText("Columna:");
        if (inDialog.exec() == QInputDialog::Rejected) {
            QMessageBox mBox(this);
            mBox.setWindowTitle("ERROR");
            mBox.setIcon(QMessageBox::Critical);
            mBox.setText(
            "No se puede continuar con la operación de agregado");
            mBox.exec();
            return;
        }
        afterOfString = inDialog.textValue();
    }
    QString queryString = "ALTER TABLE " + tableName + " ADD COLUMN " +
    columnNameLineEdit.text() + " " + typeComboBox.currentText();
    if (typeComboBox.currentText() == "VARCHAR" ||
        typeComboBox.currentText() == "VARBINARY") {
            queryString += "(" + QString::number(lenght) + ")";
    }
    if (afterOfRadioButton.isChecked()) {
        queryString += " AFTER " + afterOfString;
    }
    queryString += ";";
    QSqlQuery query(*db);
    query.exec(queryString);
    if (query.lastError().isValid()) {
        QMessageBox mBox(this);
        mBox.setWindowTitle("ERROR");
        mBox.setIcon(QMessageBox::Critical);
        mBox.setText("No se puede realizar la operación de agregado");
        mBox.exec();
        return;
    }
    QString strQuery;
    if (engineName == "sqlite") {
        strQuery = QString("PRAGMA table_info(%1)").arg(tableName);
    } else if (engineName == "mysql") {
        strQuery = QString("SHOW COLUMNS FROM %1").arg(tableName);
    }
    queryModel->setQuery(strQuery);
    counterOfColumns->setText(QString::number(queryModel->rowCount()));
}