Example #1
0
MetaEditor::MetaEditor(QWidget *parent)
  : QDialog(parent),
    m_mainWindow(qobject_cast<MainWindow *>(parent)),
    m_Relator(MarcRelators::instance()),
    m_RemoveRow(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Delete),this, 0, 0, Qt::WidgetWithChildrenShortcut))
{
    setupUi(this);

    m_book = m_mainWindow->GetCurrentBook();
    m_version = m_book->GetConstOPF()->GetEpubVersion();
    m_opfdata = m_book->GetOPF()->GetText();

    QStringList headers;
    headers << tr("Name") << tr("Value");

    QString data = GetOPFMetadata();

    TreeModel *model = new TreeModel(headers, data);
    view->setModel(model);
    for (int column = 0; column < model->columnCount(); ++column)
        view->resizeColumnToContents(column);

    if (!isVisible()) {
        ReadSettings();
    }

    if (m_version.startsWith('3')) { 
        loadMetadataElements();
        loadMetadataProperties();
    } else {
        loadE2MetadataElements();
        loadE2MetadataProperties();
    }

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

    connect(delButton, SIGNAL(clicked()), this, SLOT(removeRow()));
    connect(tbMoveUp, SIGNAL(clicked()), this, SLOT(moveRowUp()));
    connect(tbMoveDown, SIGNAL(clicked()), this, SLOT(moveRowDown()));
    connect(m_RemoveRow, SIGNAL(activated()), this, SLOT(removeRow()));

    if (m_version.startsWith('3')) {
        connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectElement()));
        connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectProperty()));
    } else {
        connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectE2Element()));
        connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectE2Property()));
    }

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveData()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    updateActions();
}
Example #2
0
void ScheduleDialog::initTimingWidget()
{
    graph_ = new BlockGraph(project_);
    blocks_ = graph_->blocks();

    // remove all MuxModel nodes from list
    QValueList<BlockNode*>::Iterator it;
    for (it = blocks_.begin(); it != blocks_.end(); ++it) {
        if (INSTANCEOF((*it)->model(), MuxModel)) {
            it = blocks_.remove(it);
        }
    }

    timingTable = new QTable(0, 4, topWidget, "timingWidget");
    timingTable->horizontalHeader()->setLabel(0, tr( "Block" ));
    timingTable->horizontalHeader()->setLabel(1, tr( "Runtime" ));
    timingTable->horizontalHeader()->setLabel(2, tr( "Clock" ));
    timingTable->horizontalHeader()->setLabel(3, tr( "Offset" ));

    timingTable->setSelectionMode(QTable::SingleRow);
    timingTable->setReadOnly(false);
    timingTable->setFocusStyle(QTable::FollowStyle);
    timingTable->setRowMovingEnabled(false);

    connect(timingTable, SIGNAL(valueChanged(int, int)),
            this, SLOT(modelChanged(int,int)));

    for (it = blocks_.begin(); it != blocks_.end(); ++it) {
        fillTimingTable(*it);
    }

    topLayout->addWidget(timingTable);

    rightWidget_ = new QWidget(topWidget);
    rightLayout_ = new QVBoxLayout(rightWidget_);
    topLayout->addWidget(rightWidget_);

    QPushButton *upPushButton_
        = new PixmapButton(QPixmap(Util::findIcon("1uparrow.png")),
                           rightWidget_);
    connect(upPushButton_, SIGNAL(clicked()), this, SLOT(moveRowUp()));

    QPushButton *downPushButton_
        = new PixmapButton(QPixmap(Util::findIcon("1downarrow.png")),
                          rightWidget_);
    connect(downPushButton_, SIGNAL(clicked()), this, SLOT(moveRowDown()));

    rightLayout_->addStretch(1);
    rightLayout_->addWidget(upPushButton_);
    rightLayout_->addWidget(downPushButton_);
    rightLayout_->addStretch(1);
}
Example #3
0
EditorWidget::EditorWidget():m_isModified(false) {
    m_RPropRadio = new QRadioButton(QLatin1String("RProperty"));
    m_CRepRadio = new QRadioButton(QLatin1String("CRepository"));
    QButtonGroup *targetGroup = new QButtonGroup(this);
    targetGroup->addButton(m_CRepRadio);
    targetGroup->addButton(m_RPropRadio);
    targetGroup->setExclusive(true);
    connect(targetGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(targetChanged(QAbstractButton *)));

    QHBoxLayout *targetLayout = new QHBoxLayout;
    targetLayout->addWidget(m_RPropRadio);
    targetLayout->addWidget(m_CRepRadio);

    m_RPropRadio->setChecked(true);
    m_repoLabel = new QLabel(tr("Category ID"), this);
    m_repoUID = new QLineEdit(this);
    QRegExpValidator *validator =
        new QRegExpValidator(QRegExp(QLatin1String("([0-9]|[A-F]|[a-f]){1,8}")), this);
    m_repoUID->setValidator(validator);
    connect(m_repoUID, SIGNAL(textEdited(const QString &)), this, SLOT(setModified()));
    m_repoUID->setToolTip(tr("Must be a hexidecimal number no longer than 8 digits"));

    QHBoxLayout *repoLayout = new QHBoxLayout;
    repoLayout->addWidget(m_repoLabel);
    repoLayout->addWidget(m_repoUID);

    QStringList headers;
    headers << tr("Key ID")  << tr("Key path");

#ifdef INCL_TYPE
    headers << tr("Type");
#endif

    m_tableWidget = new QTableWidget(0,headers.count());
    connect(m_tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(setModified()));
    m_tableWidget->setHorizontalHeaderLabels(headers);
    m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    m_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);

    m_keyIdDelegate = new KeyIdDelegate(m_tableWidget);
    m_tableWidget->setItemDelegateForColumn(EditorWidget::KeyId, m_keyIdDelegate);

    m_pathDelegate = new PathDelegate(m_tableWidget);
    m_tableWidget->setItemDelegateForColumn(EditorWidget::Path, m_pathDelegate);

#ifdef INCL_TYPE
    m_typeDelegate = new TypeDelegate(m_tableWidget);
    m_tableWidget->setItemDelegateForColumn(EditorWidget::Type,m_typeDelegate);
#endif

    m_addRowButton = new QPushButton(tr("Add Row"), this);
    connect(m_addRowButton, SIGNAL(clicked()), this, SLOT(addRow()));
    m_removeRowButton = new QPushButton(tr("Remove Row"), this);
    connect(m_removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
    QPushButton *upButton = new QPushButton(tr("/\\"), this);
    connect(upButton, SIGNAL(clicked()), this, SLOT(moveRowUp()));
    QPushButton *downButton = new QPushButton(tr("\\/"), this);
    connect(downButton, SIGNAL(clicked()), this, SLOT(moveRowDown()));

    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(m_addRowButton);
    buttonsLayout->addWidget(m_removeRowButton);
    buttonsLayout->addWidget(upButton);
    buttonsLayout->addWidget(downButton);

    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->addLayout(targetLayout);
    mainLayout->addLayout(repoLayout);
    mainLayout->addWidget(m_tableWidget);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);

    addRow();
    setModified(false);
}
Example #4
0
void TableWidget::contextMenu(const QPoint &p, bool init ){

    /*
    QModelIndex index = this->indexAt(p);
    int col = index.column();
    //int row = index.row();
    QString str = "file";
    ColumnType t = ORIGIN;
    if(col==TRACK || col==TITLE){
        str = "result";
        t = RESULT;
    }
    */


    QMenu *c = new QMenu(this);


    QAction* selectAction = new QAction("Check selected rows", this);
    selectAction->setData(true);
    connect(selectAction, SIGNAL(triggered()), this, SLOT(checkRows()));
    QAction* deselectAction = new QAction("Uncheck selected rows", this);
    deselectAction->setData(false);
    connect(deselectAction, SIGNAL(triggered()), this, SLOT(checkRows()));

    //move up/down actions for this
    QAction* moveResultUpAction = new QAction("Move result up", this);
    moveResultUpAction->setData(RESULT); moveResultUpAction->setShortcut(tr("Ctrl+U"));
    connect(moveResultUpAction, SIGNAL(triggered()), this, SLOT(moveRowUp()));
    QAction* moveResultDownAction = new QAction("Move result down", this);
    moveResultDownAction->setData(RESULT); moveResultDownAction->setShortcut(tr("Ctrl+D"));
    connect(moveResultDownAction, SIGNAL(triggered()), this, SLOT(moveRowDown()));
    QAction* moveResultToAction = new QAction("Move result to...", this);
    moveResultToAction->setData(RESULT); moveResultToAction->setShortcut(tr("Ctrl+T"));
    connect(moveResultToAction, SIGNAL(triggered()), this, SLOT(moveRowTo()));

    QAction* moveOriginUpAction = new QAction("Move file up", this);
    moveOriginUpAction->setData(ORIGIN); moveOriginUpAction->setShortcut(tr("Ctrl+Alt+U"));
    connect(moveOriginUpAction, SIGNAL(triggered()), this, SLOT(moveRowUp()));
    QAction* moveOriginDownAction = new QAction("Move file down", this);
    moveOriginDownAction->setData(ORIGIN); moveOriginDownAction->setShortcut(tr("Ctrl+Alt+D"));
    connect(moveOriginDownAction, SIGNAL(triggered()), this, SLOT(moveRowDown()));
    QAction* moveOriginToAction = new QAction("Move file to...", this);
    moveOriginToAction->setData(ORIGIN); moveOriginToAction->setShortcut(tr("Ctrl+Alt+T"));
    connect(moveOriginToAction, SIGNAL(triggered()), this, SLOT(moveRowTo()));

    QAction* sortEnabledAction = new QAction(tr("Sorting enabled"), this);
    sortEnabledAction->setCheckable(true); sortEnabledAction->setChecked( this->isSortingEnabled() );
    connect(sortEnabledAction, SIGNAL(toggled(bool)), this, SLOT(enableSorting(bool)));

    resizeColumnAction->setShortcut(tr("Ctrl+R"));
    connect(resizeColumnAction, SIGNAL(toggled(bool)), this, SLOT(resizeColumns(bool)));

    connect(resizeRowAction, SIGNAL(toggled(bool)), this, SLOT(resizeRows(bool)));
    QAction* deleteAction = new QAction(tr("Delete selected cells"), this);
    deleteAction->setShortcut(tr("Ctrl+Del"));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteCells()));

    QAction* insertBlankFileAction = new QAction("Insert empty file", this);
    insertBlankFileAction->setData(ORIGIN);
    connect(insertBlankFileAction, SIGNAL(triggered()), this, SLOT(insertBlankRow()));
    QAction* insertBlankResultAction = new QAction("Insert empty result", this);
    insertBlankResultAction->setData(RESULT);
    connect(insertBlankResultAction, SIGNAL(triggered()), this, SLOT(insertBlankRow()));

    QAction* copyAction = new QAction(tr("Copy"), this);
    copyAction->setShortcut(tr("Ctrl+C"));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copyCells()));

    QAction* pasteAction = new QAction(tr("Paste"), this);
    pasteAction->setShortcut(tr("Ctrl+V"));
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    QAction* resetAction = new QAction(tr("Reset"), this);
    connect(resetAction, SIGNAL(triggered()), this, SLOT(resetTable()));

    QMenu* matchByMenu = new QMenu(tr("Match results by..."), this);
    connect(matchByTrackAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));
    connect(matchByTitleAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));
    connect(dontMatchAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));
    connect(matchByTrackTitleAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));
    connect(matchByTitleTrackAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));
    connect(matchByFileNameAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool)));

    matchByMenu->addAction( dontMatchAction );
    matchByMenu->addAction( matchByTitleAction );
    matchByMenu->addAction( matchByTrackAction );
    matchByMenu->addAction( matchByTrackTitleAction );
    matchByMenu->addAction( matchByTitleTrackAction );
    matchByMenu->addAction( matchByFileNameAction );

    c->addMenu(matchByMenu);
    c->addSeparator();
    //if(col==FILE_NAME){
    c->addAction(deselectAction);
    c->addAction(selectAction);
    c->addSeparator();
    //}
    c->addAction(moveResultUpAction);
    c->addAction(moveResultDownAction);
    c->addAction(moveResultToAction);
    c->addAction(moveOriginUpAction);
    c->addAction(moveOriginDownAction);
    c->addAction(moveOriginToAction);
    c->addSeparator();
    c->addAction(resizeColumnAction);
    c->addAction(resizeRowAction);
    c->addAction(sortEnabledAction);
    c->addSeparator();
    c->addAction(copyAction);
    c->addAction(pasteAction);
    c->addAction(deleteAction);
    c->addSeparator();
    c->addAction(insertBlankFileAction);
    c->addAction(insertBlankResultAction);    
    c->addSeparator();
    c->addAction(resetAction);


    QPoint globalPos = this->mapToGlobal(p);
    //menu->exec( globalPos );
    if(!init){
        c->exec(globalPos);
    }else{
        this->addAction( dontMatchAction );
        this->addAction( matchByTitleAction );
        this->addAction( matchByTrackAction );
        this->addAction( matchByTrackTitleAction );
        this->addAction( matchByTitleTrackAction );
        this->addAction( matchByFileNameAction );

        this->addAction(deselectAction);
        this->addAction(selectAction);

        this->addAction(moveResultUpAction);
        this->addAction(moveResultDownAction);
        this->addAction(moveResultToAction);
        this->addAction(moveOriginUpAction);
        this->addAction(moveOriginDownAction);
        this->addAction(moveOriginToAction);

        this->addAction(resizeColumnAction);
        this->addAction(resizeRowAction);
        this->addAction(sortEnabledAction);

        this->addAction(copyAction);
        this->addAction(pasteAction);
        this->addAction(deleteAction);

        this->addAction(insertBlankFileAction);
        this->addAction(insertBlankResultAction);

    }
}