MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); QStringList headers; headers << tr("Title") << tr("Description"); QFile file(":/default.txt"); file.open(QIODevice::ReadOnly); TreeModel *model = new TreeModel(headers, file.readAll()); file.close(); view->setModel(model); for (int column = 0; column < model->columnCount(); ++column) view->resizeColumnToContents(column); connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateActions())); connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions())); connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow())); connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn())); connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow())); connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn())); connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild())); updateActions(); }
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(); }