-void SimpleTextView::convertFromUTF16LE()
-{
- QTextCodec *codec = QTextCodec::codecForName("UTF-16LE");
- setPlainText(codec->toUnicode(m_source));
- getMainWnd()->statusBar()->showMessage("UTF-16LE");
-}
-
-void SimpleTextView::back()
-{
- emit viewFinished(this);
-}
-
-void SimpleTextView::keyPressEvent(QKeyEvent *event)
-{
- QString modifier = QString::null;
- if (event->modifiers() & Qt::ShiftModifier) { modifier += "Shift+"; }
- if (event->modifiers() & Qt::ControlModifier) { modifier += "Ctrl+"; }
- if (event->modifiers() & Qt::AltModifier) { modifier += "Alt+"; }
- if (event->modifiers() & Qt::MetaModifier) { modifier += "Meta+"; }
-
- QString key = QKeySequence(event->key()).toString();
- QString ksq = QKeySequence(modifier + key).toString();
-
- if (ksq == "Return" || ksq == "Backspace" || ksq == "W") {
- emit viewFinished(this);
- event->accept();
- return;
- }
-
- if (!ksq.isEmpty()) {
- foreach (QObject *obj, this->children()) {
- QAction *action = qobject_cast<QAction*>(obj);
- if (action && action->isEnabled()) {
- foreach (const QKeySequence &keySeq, action->shortcuts()) {
- if (ksq == keySeq.toString()) {
- qDebug() << "emit " << ksq << " " << action->objectName();
- emit action->triggered();
- event->accept();
- return;
- }
- }
- }
- }
-
- foreach (QObject *obj, getMainWnd()->children()) {
- QAction *action = qobject_cast<QAction*>(obj);
- if (action && action->isEnabled()) {
- foreach (const QKeySequence &keySeq, action->shortcuts()) {
- if (ksq == keySeq.toString()) {
- qDebug() << "emit " << ksq << " " << action->objectName();
- emit action->triggered();
- event->accept();
- return;
- }
- }
- }
- }
- }
-
- if (ksq != "Down" && ksq != "Up") {
- qDebug() << ksq;
- }
-
- QPlainTextEdit::keyPressEvent(event);
-}
-
-
-void SimpleTextView::contextMenuEvent(QContextMenuEvent *event)
-{
- qDebug() << "contextMenuEvent();";
- QMenu menu(this);
- menu.addAction(m_convEUC);
- menu.addAction(m_convJIS);
- menu.addAction(m_convSJIS);
- menu.addAction(m_convUTF8);
- menu.addAction(m_convUTF16BE);
- menu.addAction(m_convUTF16LE);
- menu.addAction(m_back);
- menu.exec(event->globalPos());