[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 885121fe2a3d91ccca86282712fd4423efe7f97d
Eugeniy Meshcheryakov
eugen at debian.org
Wed Aug 29 12:05:45 UTC 2007
The branch, master has been updated
via 885121fe2a3d91ccca86282712fd4423efe7f97d (commit)
via d7a00d07079ccaaf95d414de95b864e7354138ed (commit)
via 6b63c0f719e03dd6dd3fc7a479a9a7e9695ec15d (commit)
via 321fa576dd58be3b4eb5f738457f0ca2bea87e5c (commit)
from 652ae48c9b04cab79af1079933919ebd0f61cad0 (commit)
- Shortlog ------------------------------------------------------------
885121f add buttons for changing CVT entries count
d7a00d0 add missing setChanged()
6b63c0f add funtcions for CVT resising
321fa57 read and write additional parameters of CVT entries
Summary of changes:
gui/cvteditor.cxx | 51 +++++++++++++++++++++++++++++++++++++---
gui/cvteditor.h | 8 ++++++
gui/gui.rules | 3 +-
nongui/cvtmodel.cxx | 32 +++++++++++++++++++++++++
nongui/cvtmodel.h | 2 +
nongui/fontdocument.cxx | 14 +++++++++++
nongui/fontdocument.h | 2 +
nongui/fontdocumentreader.cxx | 3 +-
nongui/fontdocumentwriter.cxx | 5 +++-
9 files changed, 113 insertions(+), 7 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit 885121fe2a3d91ccca86282712fd4423efe7f97d
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Wed Aug 29 14:05:33 2007 +0200
add buttons for changing CVT entries count
diff --git a/gui/cvteditor.cxx b/gui/cvteditor.cxx
index 34819a6..4276adc 100644
--- a/gui/cvteditor.cxx
+++ b/gui/cvteditor.cxx
@@ -16,7 +16,9 @@
*/
#include "cvteditor.h"
#include <QHBoxLayout>
+#include <QVBoxLayout>
#include <QTableView>
+#include <QPushButton>
CVTEditor::CVTEditor(class QAbstractItemModel *model, QWidget *parent) : QDialog(parent)
{
@@ -27,11 +29,52 @@ CVTEditor::CVTEditor(class QAbstractItemModel *model, QWidget *parent) : QDialog
Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags & ~Qt::Dialog | Qt::Window);
- QHBoxLayout *hbox = new QHBoxLayout;
+ // TODO make some better layout
+ QVBoxLayout *vbox = new QVBoxLayout;
- QTableView *table = new QTableView;
+ table = new QTableView;
table->setModel(model);
- hbox->addWidget(table);
- setLayout(hbox);
+ QHBoxLayout *hbox = new QHBoxLayout;
+ QPushButton *addRowButton = new QPushButton("Add Entry");
+ QPushButton *removeRowButton = new QPushButton("Remove Entry");
+ QPushButton *clearButton = new QPushButton("Clear");
+ hbox->addWidget(addRowButton);
+ hbox->addWidget(removeRowButton);
+ hbox->addWidget(clearButton);
+
+ connect(addRowButton, SIGNAL(clicked()), this, SLOT(addRow()));
+ connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
+ connect(clearButton, SIGNAL(clicked()), this, SLOT(clearTable()));
+
+ vbox->addLayout(hbox);
+ vbox->addWidget(table);
+
+ setLayout(vbox);
+}
+
+void CVTEditor::addRow()
+{
+ Q_ASSERT(table);
+ QAbstractItemModel *model = table->model();
+ Q_ASSERT(model);
+ model->insertRow(model->rowCount());
+}
+
+void CVTEditor::removeRow()
+{
+ Q_ASSERT(table);
+ QAbstractItemModel *model = table->model();
+ Q_ASSERT(model);
+ if (model->rowCount())
+ model->removeRow(model->rowCount() - 1);
+}
+
+void CVTEditor::clearTable()
+{
+ Q_ASSERT(table);
+ QAbstractItemModel *model = table->model();
+ Q_ASSERT(model);
+ if (model->rowCount())
+ model->removeRows(0, model->rowCount());
}
diff --git a/gui/cvteditor.h b/gui/cvteditor.h
index 0f300b1..5e447d2 100644
--- a/gui/cvteditor.h
+++ b/gui/cvteditor.h
@@ -19,11 +19,19 @@
#include <QDialog>
class QAbstractItemModel;
+class QTableView;
class CVTEditor : public QDialog
{
+ Q_OBJECT
public:
CVTEditor(QAbstractItemModel *model, QWidget *parent = 0);
+public slots:
+ void addRow();
+ void removeRow();
+ void clearTable();
+private:
+ QTableView *table;
};
#endif
diff --git a/gui/gui.rules b/gui/gui.rules
index 0983bb1..254a9bf 100644
--- a/gui/gui.rules
+++ b/gui/gui.rules
@@ -31,7 +31,8 @@ nodist_libfonduegui_a_SOURCES = \
gui/ttieditor.moc.cxx \
gui/glyphsmodel.moc.cxx \
gui/glyphsmodeldelegate.moc.cxx \
- gui/unicodeproxymodel.moc.cxx
+ gui/unicodeproxymodel.moc.cxx \
+ gui/cvteditor.moc.cxx
gui/instnames.tbl.cxx: data/instructions.xml
gui/instnames.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
commit d7a00d07079ccaaf95d414de95b864e7354138ed
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Wed Aug 29 13:59:06 2007 +0200
add missing setChanged()
diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index d535d95..3b4f4e9 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -143,4 +143,5 @@ void FontDocument::insertCvtEntries(int first, int count)
{
Q_ASSERT(first >= 0 && first <= m_cvt.size());
m_cvt.insert(first, count, CVTEntry());
+ setChanged();
}
commit 6b63c0f719e03dd6dd3fc7a479a9a7e9695ec15d
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Tue Aug 28 19:48:40 2007 +0200
add funtcions for CVT resising
diff --git a/nongui/cvtmodel.cxx b/nongui/cvtmodel.cxx
index 74994dd..b283206 100644
--- a/nongui/cvtmodel.cxx
+++ b/nongui/cvtmodel.cxx
@@ -117,3 +117,35 @@ Qt::ItemFlags CVTModel::flags(const QModelIndex &index) const
return 0;
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
+
+bool CVTModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ if (parent.isValid())
+ return false;
+ Q_ASSERT(count > 0 && row >= 0);
+
+ if (row + count > m_doc->cvt().size())
+ return false;
+
+ beginRemoveRows(parent, row, row + count - 1);
+ m_doc->removeCvtEntries(row, count);
+ endRemoveRows();
+
+ return false;
+}
+
+bool CVTModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ if (parent.isValid())
+ return false;
+ Q_ASSERT(count > 0 && row >= 0);
+
+ if (row > m_doc->cvt().size())
+ return false;
+
+ beginInsertRows(parent, row, row + count - 1);
+ m_doc->insertCvtEntries(row, count);
+ endInsertRows();
+
+ return false;
+}
diff --git a/nongui/cvtmodel.h b/nongui/cvtmodel.h
index 4b582f9..771a606 100644
--- a/nongui/cvtmodel.h
+++ b/nongui/cvtmodel.h
@@ -30,6 +30,8 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
private:
FontDocument *m_doc;
};
diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index b151e6f..d535d95 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -131,3 +131,16 @@ bool FontDocument::changeCvtEntry(int index, const CVTEntry &newEntry)
setChanged();
return true;
}
+
+void FontDocument::removeCvtEntries(int first, int count)
+{
+ Q_ASSERT(first >= 0 && first + count <= m_cvt.size());
+ m_cvt.remove(first, count);
+ setChanged();
+}
+
+void FontDocument::insertCvtEntries(int first, int count)
+{
+ Q_ASSERT(first >= 0 && first <= m_cvt.size());
+ m_cvt.insert(first, count, CVTEntry());
+}
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index aa3c309..b01d6a1 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -123,6 +123,8 @@ public:
bool changeInstructions(Glyph *glyph, const QString &newInstructions);
bool changeCvtEntry(int index, const CVTEntry &newEntry);
+ void removeCvtEntries(int first, int count);
+ void insertCvtEntries(int first, int count);
signals:
void documentChanged();
private:
commit 321fa576dd58be3b4eb5f738457f0ca2bea87e5c
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Tue Aug 28 19:47:32 2007 +0200
read and write additional parameters of CVT entries
diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 10f35c8..7f56c74 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -459,7 +459,8 @@ void FontDocumentReader::readCvt()
raiseError("cv: invalid value for attribute v");
return;
}
- doc->addCvtEntry(val);
+ doc->addCvtEntry(val, attributes().value("name").toString(),
+ attributes().value("comm").toString());
readUnknownElement();
}
else
diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index a8d727c..4813493 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -95,8 +95,11 @@ bool FontDocumentWriter::writeInstructionTables()
writeStartElement("cvt");
foreach (const CVTEntry &cv, doc->cvt()) {
writeEmptyElement("cv");
- // TODO other attributes
writeAttribute("v", QString::number(cv.value()));
+ if (!cv.variableName().isEmpty())
+ writeAttribute("name", cv.variableName());
+ if (!cv.comment().isEmpty())
+ writeAttribute("comm", cv.comment());
}
writeEndElement(); // cvt
}
--
Fondue Font Editor
More information about the fondue-commits
mailing list