Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lintest/fb2edit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-09-28 12:35:46 +0400
committerKandrashin Denis <mail@lintest.ru>2012-09-28 12:35:46 +0400
commitd6c4c70f19f02c45d439e6298c55bac806c41f37 (patch)
tree8bb2efc23d44a5be66f5c3edae3b3ae4b0b34439
parent1f3d22d7630a95ea33c71a664e3cfc9b089eccd1 (diff)
Small changes
-rw-r--r--source/fb2head.cpp66
-rw-r--r--source/fb2head.hpp22
2 files changed, 71 insertions, 17 deletions
diff --git a/source/fb2head.cpp b/source/fb2head.cpp
index 5c137fe..56176b7 100644
--- a/source/fb2head.cpp
+++ b/source/fb2head.cpp
@@ -486,14 +486,15 @@ FbHeadView::FbHeadView(FbTextEdit *view, QWidget *parent)
//setItemDelegate(new QItemDelegate(this));
setRootIsDecorated(false);
- setSelectionBehavior(QAbstractItemView::SelectRows);
+ setSelectionBehavior(QAbstractItemView::SelectItems);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
connect(&m_view, SIGNAL(loadFinished(bool)), SLOT(updateTree()));
connect(this, SIGNAL(activated(QModelIndex)), SLOT(activated(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), SLOT(collapsed(QModelIndex)));
header()->setDefaultSectionSize(200);
- connect(actionModify, SIGNAL(triggered()), SLOT(editCurrent()));
+// connect(this, SIGNAL(activated(QModelIndex)), SLOT(editCurrent(QModelIndex)));
+// connect(actionModify, SIGNAL(triggered()), SLOT(editCurrent()));
}
void FbHeadView::initToolbar(QToolBar &toolbar)
@@ -510,15 +511,18 @@ void FbHeadView::updateTree()
model->expand(this);
}
-void FbHeadView::editCurrent()
+void FbHeadView::editCurrent(const QModelIndex &index)
{
- if (!model()) return;
- QModelIndex current = currentIndex();
- if (!current.isValid()) return;
- QModelIndex parent = model()->parent(current);
- QModelIndex index = model()->index(current.row(), 1, parent);
- setCurrentIndex(index);
- edit(index);
+ FbHeadModel * m = qobject_cast<FbHeadModel*>(model());
+ if (!m) return;
+
+ FbHeadItem * item = m->item(index);
+ if (!item) return;
+
+ FbNodeEditDlg dlg(this, item->scheme(), item->element());
+ if (dlg.exec()) {
+ //TODO
+ }
}
void FbHeadView::activated(const QModelIndex &index)
@@ -576,7 +580,11 @@ void FbHeadView::appendNode()
FbNodeDlg dlg(this, item->scheme(), list);
if (dlg.exec()) {
current = m->append(current, dlg.value());
- if (current.isValid()) setCurrentIndex(current);
+ if (current.isValid()) {
+ setCurrentIndex(current);
+ scrollTo(current);
+ expand(current);
+ }
}
}
@@ -594,7 +602,7 @@ QModelIndex FbHeadModel::append(const QModelIndex &parent, const QString &name)
beginInsertRows(parent, row, row);
FbHeadItem * item = owner->append(name);
endInsertRows();
- return createIndex(row, 0, (void*)item);
+ return createIndex(row, 1, (void*)item);
}
void FbHeadModel::remove(const QModelIndex &index)
@@ -611,7 +619,7 @@ void FbHeadModel::remove(const QModelIndex &index)
// FbNodeDlg
//---------------------------------------------------------------------------
-FbNodeDlg::FbNodeDlg(QWidget *parent, FbScheme scheme, QStringList &list)
+FbNodeDlg::FbNodeDlg(QWidget *parent, const FbScheme &scheme, const QStringList &list)
: QDialog(parent)
, m_scheme(scheme)
{
@@ -620,7 +628,6 @@ FbNodeDlg::FbNodeDlg(QWidget *parent, FbScheme scheme, QStringList &list)
QGridLayout * layout = new QGridLayout(this);
QLabel * label = new QLabel(this);
- label->setObjectName(QString::fromUtf8("label"));
label->setText(tr("Tag name:"));
layout->addWidget(label, 0, 0, 1, 1);
@@ -664,6 +671,37 @@ QString FbNodeDlg::value() const
}
//---------------------------------------------------------------------------
+// FbNodeEditDlg
+//---------------------------------------------------------------------------
+
+FbNodeEditDlg::FbNodeEditDlg(QWidget *parent, const FbScheme &scheme, const QWebElement &element)
+ : QDialog(parent)
+ , m_scheme(scheme)
+ , m_element(element)
+{
+ setWindowTitle(tr("Modify tag"));
+
+ QGridLayout * layout = new QGridLayout(this);
+
+ QLabel *label = new QLabel(this);
+ label->setText(tr("Value:"));
+ layout->addWidget(label, 0, 0, 1, 1);
+
+ QLineEdit *edit = new QLineEdit(this);
+ layout->addWidget(edit, 0, 1, 1, 1);
+
+ QDialogButtonBox * buttons = new QDialogButtonBox(this);
+ buttons->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
+ buttons->setOrientation(Qt::Horizontal);
+ layout->addWidget(buttons, 2, 0, 1, 2);
+
+ layout->setColumnStretch(1, 1);
+
+ connect(buttons, SIGNAL(accepted()), SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), SLOT(reject()));
+}
+
+//---------------------------------------------------------------------------
// FbAuthorDlg
//---------------------------------------------------------------------------
diff --git a/source/fb2head.hpp b/source/fb2head.hpp
index 68cee58..4949582 100644
--- a/source/fb2head.hpp
+++ b/source/fb2head.hpp
@@ -87,6 +87,10 @@ public:
return m_parent;
}
+ QWebElement element() const {
+ return m_element;
+ }
+
QString text(int col = 0) const;
void setText(const QString &text);
@@ -163,7 +167,7 @@ signals:
void status(const QString &text);
public slots:
- void editCurrent();
+ void editCurrent(const QModelIndex &index);
void updateTree();
private slots:
@@ -190,18 +194,30 @@ class FbNodeDlg : public QDialog
Q_OBJECT
public:
- explicit FbNodeDlg(QWidget *parent, FbScheme scheme, QStringList &list);
+ explicit FbNodeDlg(QWidget *parent, const FbScheme &scheme, const QStringList &list);
QString value() const;
private slots:
void comboChanged(const QString &text);
private:
- const FbScheme m_scheme;
+ const FbScheme &m_scheme;
QComboBox * m_combo;
QLabel * m_text;
};
+class FbNodeEditDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit FbNodeEditDlg(QWidget *parent, const FbScheme &scheme, const QWebElement &element);
+
+private:
+ const FbScheme &m_scheme;
+ QWebElement m_element;
+};
+
class FbAuthorDlg : public QDialog
{
Q_OBJECT