Changeset View
Changeset View
Standalone View
Standalone View
addons/xmltools/plugin_katexmltools.cpp
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 116 | PluginKateXMLToolsView::PluginKateXMLToolsView(KTextEditor::MainWindow *mainWin) | |||
---|---|---|---|---|---|
120 | , m_model(this) | 120 | , m_model(this) | ||
121 | { | 121 | { | ||
122 | //qDebug() << "PluginKateXMLTools constructor called"; | 122 | //qDebug() << "PluginKateXMLTools constructor called"; | ||
123 | 123 | | |||
124 | KXMLGUIClient::setComponentName(QLatin1String("katexmltools"), i18n("Kate XML Tools")); | 124 | KXMLGUIClient::setComponentName(QLatin1String("katexmltools"), i18n("Kate XML Tools")); | ||
125 | setXMLFile(QLatin1String("ui.rc")); | 125 | setXMLFile(QLatin1String("ui.rc")); | ||
126 | 126 | | |||
127 | QAction *actionInsert = new QAction(i18n("&Insert Element..."), this); | 127 | QAction *actionInsert = new QAction(i18n("&Insert Element..."), this); | ||
128 | connect(actionInsert, SIGNAL(triggered()), &m_model, SLOT(slotInsertElement())); | 128 | connect(actionInsert, &QAction::triggered, &m_model, &PluginKateXMLToolsCompletionModel::slotInsertElement); | ||
129 | actionCollection()->addAction("xml_tool_insert_element", actionInsert); | 129 | actionCollection()->addAction("xml_tool_insert_element", actionInsert); | ||
130 | actionCollection()->setDefaultShortcut(actionInsert, Qt::CTRL + Qt::Key_Return); | 130 | actionCollection()->setDefaultShortcut(actionInsert, Qt::CTRL + Qt::Key_Return); | ||
131 | 131 | | |||
132 | QAction *actionClose = new QAction(i18n("&Close Element"), this); | 132 | QAction *actionClose = new QAction(i18n("&Close Element"), this); | ||
133 | connect(actionClose, SIGNAL(triggered()), &m_model, SLOT(slotCloseElement())); | 133 | connect(actionClose, &QAction::triggered, &m_model, &PluginKateXMLToolsCompletionModel::slotCloseElement); | ||
134 | actionCollection()->addAction("xml_tool_close_element", actionClose); | 134 | actionCollection()->addAction("xml_tool_close_element", actionClose); | ||
135 | actionCollection()->setDefaultShortcut(actionClose, Qt::CTRL + Qt::Key_Less); | 135 | actionCollection()->setDefaultShortcut(actionClose, Qt::CTRL + Qt::Key_Less); | ||
136 | 136 | | |||
137 | QAction *actionAssignDTD = new QAction(i18n("Assign Meta &DTD..."), this); | 137 | QAction *actionAssignDTD = new QAction(i18n("Assign Meta &DTD..."), this); | ||
138 | connect(actionAssignDTD, SIGNAL(triggered()), &m_model, SLOT(getDTD())); | 138 | connect(actionAssignDTD, &QAction::triggered, &m_model, &PluginKateXMLToolsCompletionModel::getDTD); | ||
139 | actionCollection()->addAction("xml_tool_assign", actionAssignDTD); | 139 | actionCollection()->addAction("xml_tool_assign", actionAssignDTD); | ||
140 | 140 | | |||
141 | mainWin->guiFactory()->addClient(this); | 141 | mainWin->guiFactory()->addClient(this); | ||
142 | 142 | | |||
143 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentDeleted(KTextEditor::Document *)), | 143 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentDeleted, | ||
144 | &m_model, SLOT(slotDocumentDeleted(KTextEditor::Document *))); | 144 | &m_model, &PluginKateXMLToolsCompletionModel::slotDocumentDeleted); | ||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | PluginKateXMLToolsView::~PluginKateXMLToolsView() | 147 | PluginKateXMLToolsView::~PluginKateXMLToolsView() | ||
148 | { | 148 | { | ||
149 | m_mainWindow->guiFactory()->removeClient(this); | 149 | m_mainWindow->guiFactory()->removeClient(this); | ||
150 | 150 | | |||
151 | //qDebug() << "xml tools descructor 1..."; | 151 | //qDebug() << "xml tools descructor 1..."; | ||
152 | //TODO: unregister the model | 152 | //TODO: unregister the model | ||
▲ Show 20 Lines • Show All 319 Lines • ▼ Show 20 Line(s) | 380 | { | |||
472 | if (m_dtds[ m_urlString ]) { | 472 | if (m_dtds[ m_urlString ]) { | ||
473 | assignDTD(m_dtds[ m_urlString ], kv); | 473 | assignDTD(m_dtds[ m_urlString ], kv); | ||
474 | } else { | 474 | } else { | ||
475 | m_dtdString.clear(); | 475 | m_dtdString.clear(); | ||
476 | m_viewToAssignTo = kv; | 476 | m_viewToAssignTo = kv; | ||
477 | 477 | | |||
478 | QGuiApplication::setOverrideCursor(Qt::WaitCursor); | 478 | QGuiApplication::setOverrideCursor(Qt::WaitCursor); | ||
479 | KIO::Job *job = KIO::get(url); | 479 | KIO::Job *job = KIO::get(url); | ||
480 | connect(job, SIGNAL(result(KJob *)), this, SLOT(slotFinished(KJob *))); | 480 | connect(job, &KIO::Job::result, this, &PluginKateXMLToolsCompletionModel::slotFinished); | ||
481 | connect(job, SIGNAL(data(KIO::Job *, QByteArray)), | 481 | connect(job, SIGNAL(data(KIO::Job *, QByteArray)), | ||
482 | this, SLOT(slotData(KIO::Job *, QByteArray))); | 482 | this, SLOT(slotData(KIO::Job *, QByteArray))); | ||
483 | } | 483 | } | ||
484 | qDebug() << "XMLTools::getDTD: Documents: " << m_docDtds.count() << ", DTDs: " << m_dtds.count(); | 484 | qDebug() << "XMLTools::getDTD: Documents: " << m_docDtds.count() << ", DTDs: " << m_dtds.count(); | ||
dhaumann: also remove? :) | |||||
485 | } | 485 | } | ||
486 | 486 | | |||
487 | void PluginKateXMLToolsCompletionModel::slotFinished(KJob *job) | 487 | void PluginKateXMLToolsCompletionModel::slotFinished(KJob *job) | ||
488 | { | 488 | { | ||
489 | if (job->error()) { | 489 | if (job->error()) { | ||
490 | //qDebug() << "XML Plugin error: DTD in XML format (" << filename << " ) could not be loaded"; | 490 | //qDebug() << "XML Plugin error: DTD in XML format (" << filename << " ) could not be loaded"; | ||
491 | static_cast<KIO::Job *>(job)->uiDelegate()->showErrorMessage(); | 491 | static_cast<KIO::Job *>(job)->uiDelegate()->showErrorMessage(); | ||
492 | } else if (static_cast<KIO::TransferJob *>(job)->isErrorPage()) { | 492 | } else if (static_cast<KIO::TransferJob *>(job)->isErrorPage()) { | ||
▲ Show 20 Lines • Show All 575 Lines • ▼ Show 20 Line(s) | 1064 | { | |||
1068 | 1068 | | |||
1069 | // label | 1069 | // label | ||
1070 | QString text = i18n("Enter XML tag name and attributes (\"<\", \">\" and closing tag will be supplied):"); | 1070 | QString text = i18n("Enter XML tag name and attributes (\"<\", \">\" and closing tag will be supplied):"); | ||
1071 | QLabel *label = new QLabel(text, this); | 1071 | QLabel *label = new QLabel(text, this); | ||
1072 | label->setWordWrap(true); | 1072 | label->setWordWrap(true); | ||
1073 | // combo box | 1073 | // combo box | ||
1074 | m_cmbElements = new KHistoryComboBox(this); | 1074 | m_cmbElements = new KHistoryComboBox(this); | ||
1075 | static_cast<KHistoryComboBox*>(m_cmbElements)->setHistoryItems(completions, true); | 1075 | static_cast<KHistoryComboBox*>(m_cmbElements)->setHistoryItems(completions, true); | ||
1076 | connect(m_cmbElements->lineEdit(), SIGNAL(textChanged(QString)), | 1076 | connect(m_cmbElements->lineEdit(), &QLineEdit::textChanged, this, &InsertElement::slotHistoryTextChanged); | ||
1077 | this, SLOT(slotHistoryTextChanged(QString))); | | |||
1078 | 1077 | | |||
1079 | // button box | 1078 | // button box | ||
1080 | QDialogButtonBox * box = new QDialogButtonBox(this); | 1079 | QDialogButtonBox * box = new QDialogButtonBox(this); | ||
1081 | box->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | 1080 | box->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
1082 | m_okButton = box->button(QDialogButtonBox::Ok); | 1081 | m_okButton = box->button(QDialogButtonBox::Ok); | ||
1083 | m_okButton->setDefault(true); | 1082 | m_okButton->setDefault(true); | ||
1084 | 1083 | | |||
1085 | connect(box, SIGNAL(accepted()), this, SLOT(accept())); | 1084 | connect(box, &QDialogButtonBox::accepted, this, &InsertElement::accept); | ||
1086 | connect(box, SIGNAL(rejected()), this, SLOT(reject())); | 1085 | connect(box, &QDialogButtonBox::rejected, this, &InsertElement::reject); | ||
1087 | 1086 | | |||
1088 | // fill layout | 1087 | // fill layout | ||
1089 | topLayout->addWidget(label); | 1088 | topLayout->addWidget(label); | ||
1090 | topLayout->addWidget(m_cmbElements); | 1089 | topLayout->addWidget(m_cmbElements); | ||
1091 | topLayout->addWidget(box); | 1090 | topLayout->addWidget(box); | ||
1092 | 1091 | | |||
1093 | m_cmbElements->setFocus(); | 1092 | m_cmbElements->setFocus(); | ||
1094 | 1093 | | |||
Show All 22 Lines |
also remove? :)