コード例 #1
0
TableEditor::TableEditor(QWidget *parent): Editor(parent)
{
    QVBoxLayout *layout = new QVBoxLayout(this);
    setLayout(layout);

    // toolbar
    _toolbar = new QWidget(this);
    layout->addWidget(_toolbar);
    _ui_toolbar = new Ui::TableEditorToolbar;
    _ui_toolbar->setupUi(_toolbar);
    _ui_toolbar->firstPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allLeft")));
    _ui_toolbar->previousPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/left")));
    _ui_toolbar->nextPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/right")));
    _ui_toolbar->lastPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allRight")));

    _ui_toolbar->refreshButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/refresh")));

    _ui_toolbar->addRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/add")));
    _ui_toolbar->deleteRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/remove")));

    _ui_toolbar->commitButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/checked")));
    _ui_toolbar->rollbackButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/rollback")));

    _ui_toolbar->dumpDataButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/export")));

    _tableView = new QTableView(this);
    _tableModel = new QSqlTableModel(_tableView /* TODO database connection */);
    _tableView->setModel(_tableModel);
    layout->addWidget(_tableView);

    // connections
    connect(_ui_toolbar->commitButton, SIGNAL(clicked()), _tableModel, SLOT(submitAll()));
    connect(_ui_toolbar->rollbackButton, SIGNAL(clicked()), _tableModel, SLOT(revertAll()));
    connect(_ui_toolbar->addRowButton, SIGNAL(clicked()), this, SLOT(addRow()));
    connect(_ui_toolbar->deleteRowButton, SIGNAL(clicked()), this, SLOT(deleteRows()));
    connect(_ui_toolbar->refreshButton, SIGNAL(clicked()), _tableModel, SLOT(select()));



    connect(_ui_toolbar->toolButtonExportImage, SIGNAL(clicked()),_imageView, SLOT(exportImage()));
    connect(_ui_toolbar->toolButtonZoomIn, SIGNAL(clicked()),_imageView,SLOT(zoomIn()));
    connect(_ui_toolbar->toolButtonZoomOut, SIGNAL(clicked()),_imageView, SLOT(zoomOut()));
    connect(_ui_toolbar->toolButtonFitToScreen, SIGNAL(clicked()),_imageView, SLOT(fitToScreen()));
    connect(_ui_toolbar->toolButtonOriginalSize, SIGNAL(clicked()),_imageView, SLOT(resetToOriginalSize()));
    connect(_ui_toolbar->toolButtonBackground, SIGNAL(toggled()),_imageView, SLOT(setViewBackground()));
    connect(_ui_toolbar->toolButtonOutline, SIGNAL(toggled()),_imageView, SLOT(setViewOutline()));
    connect(_ui_toolbar->toolButtonPlayPause, SIGNAL(clicked()),this, SLOT(playToggled()));
    connect(_file, SIGNAL(imageSizeChanged()),this, SLOT(imageSizeUpdated()));
    connect(_file, SIGNAL(openFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(openFinished()),this, SLOT(updateToolButtons()));
    connect(_file, SIGNAL(aboutToReload()),_imageView, SLOT(reset()));
    connect(_file, SIGNAL(reloadFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(isPausedChanged()),this, SLOT(updatePauseAction()));
    connect(_imageView, SIGNAL(scaleFactorChanged()),this, SLOT(scaleFactorUpdate()));
}
コード例 #2
0
void FileDiffController::reload()
{
    QString errorString;
    Utils::TextFileFormat format;
    format.codec = Core::EditorManager::defaultTextCodec();

    QString leftText;
    if (Utils::TextFileFormat::readFile(m_leftFileName,
                                    format.codec,
                                    &leftText, &format, &errorString)
            != Utils::TextFileFormat::ReadSuccess) {
        return;
    }

    QString rightText;
    if (Utils::TextFileFormat::readFile(m_rightFileName,
                                    format.codec,
                                    &rightText, &format, &errorString)
            != Utils::TextFileFormat::ReadSuccess) {
        return;
    }

    Differ differ;
    QList<Diff> diffList = differ.cleanupSemantics(differ.diff(leftText, rightText));

    QList<Diff> leftDiffList;
    QList<Diff> rightDiffList;
    Differ::splitDiffList(diffList, &leftDiffList, &rightDiffList);
    QList<Diff> outputLeftDiffList;
    QList<Diff> outputRightDiffList;

    if (ignoreWhitespace()) {
        const QList<Diff> leftIntermediate
                = Differ::moveWhitespaceIntoEqualities(leftDiffList);
        const QList<Diff> rightIntermediate
                = Differ::moveWhitespaceIntoEqualities(rightDiffList);
        Differ::ignoreWhitespaceBetweenEqualities(leftIntermediate, rightIntermediate,
                                                  &outputLeftDiffList, &outputRightDiffList);
    } else {
        outputLeftDiffList = leftDiffList;
        outputRightDiffList = rightDiffList;
    }

    const ChunkData chunkData = DiffUtils::calculateOriginalData(
                outputLeftDiffList, outputRightDiffList);
    FileData fileData = DiffUtils::calculateContextData(chunkData, contextLineCount(), 0);
    fileData.leftFileInfo.fileName = m_leftFileName;
    fileData.rightFileInfo.fileName = m_rightFileName;

    QList<FileData> fileDataList;
    fileDataList << fileData;

    setDiffFiles(fileDataList);
    reloadFinished(true);
}