Commit d63cd09c authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Assorted KF5 porting

parent f26e82ab
......@@ -17,7 +17,7 @@ INCLUDE(ECMInstallIcons)
INCLUDE(FeatureSummary)
FIND_PACKAGE(Qt5 5.2 CONFIG REQUIRED COMPONENTS Widgets Core Xml Network WebKit Script)
FIND_PACKAGE(KF5 5.0 REQUIRED COMPONENTS CoreAddons DocTools I18n XmlGui TextEditor WidgetsAddons KDELibs4Support WebKit)
FIND_PACKAGE(KF5 5.0 REQUIRED COMPONENTS CoreAddons DocTools I18n XmlGui TextEditor WidgetsAddons KDELibs4Support WebKit Parts)
IF(FORCE_PRETTY_MAKEFILE)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
......
......@@ -14,4 +14,4 @@ SET(agents_STAT_SRCS
)
ADD_LIBRARY(agents STATIC ${agents_STAT_SRCS})
TARGET_LINK_LIBRARIES(agents Qt5::Widgets KF5::KDELibs4Support)
\ No newline at end of file
TARGET_LINK_LIBRARIES(agents Qt5::Widgets KF5::TextEditor KF5::KDELibs4Support)
\ No newline at end of file
......@@ -19,7 +19,7 @@
#define RKPRINTAGENT_H
#include <QObject>
#include <kparts/part.h>
#include <kparts/readonlypart.h>
/** The main purpose of this class is to cope with the lack of kprinter in KDE 4. Tries
* to offer a KDE print dialog for an existing postscript file. */
......
......@@ -22,11 +22,13 @@
#include <kmessagebox.h>
#include <kvbox.h>
#include <ktoolinvocation.h>
#include <kicon.h>
#include <QLabel>
#include <QTextEdit>
#include <QTemporaryFile>
#include <QTextStream>
#include <QPushButton>
#include "../rbackend/rinterface.h"
#include "../rbackend/rksessionvars.h"
......@@ -99,16 +101,20 @@ void RKErrorDialog::reportableErrorMessage (QWidget* parent_widget, const QStrin
// adjusted from KMessageBox::detailedError
KDialog *dialog = new KDialog (parent_widget, Qt::Dialog);
dialog->setCaption (caption);
if (details.isEmpty ()) dialog->setButtons (KDialog::Ok | KDialog::No);
else dialog->setButtons (KDialog::Ok | KDialog::No | KDialog::Details);
dialog->setButtonText (KDialog::No, i18n ("Report As Bug"));
QDialogButtonBox *buttonbox = new QDialogButtonBox (dialog);
if (details.isEmpty ()) buttonbox->setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::No);
else {
buttonbox->setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::No | QDialogButtonBox::Help);
buttonbox->button (QDialogButtonBox::Help)->setText (i18n ("Show Details"));
}
buttonbox->button (QDialogButtonBox::No)->setText (i18n ("Report As Bug"));
dialog->setObjectName ("error");
dialog->setDefaultButton (KDialog::Ok);
dialog->setEscapeButton (KDialog::Ok);
buttonbox->button (QDialogButtonBox::Ok)->setDefault (true);
buttonbox->button (QDialogButtonBox::Ok)->setShortcut (Qt::Key_Escape);
KMessageBox::Options options = KMessageBox::Notify | KMessageBox::AllowLink;
dialog->setModal (true);
int ret = KMessageBox::createKMessageBox (dialog, QMessageBox::Critical, user_message, QStringList(), QString(), 0, options, details);
int ret = KMessageBox::createKMessageBox (dialog, buttonbox, QMessageBox::Critical, user_message, QStringList(), QString(), 0, options, details);
if (ret == KDialog::No) {
reportBug (parent_widget, (message_code.isEmpty () ? QString () : i18n ("Message code: %1\n", message_code)) + user_message);
......
......@@ -36,7 +36,7 @@ RKImportDialogFormatSelector::RKImportDialogFormatSelector () : KHBox () {
combo = new QComboBox (this);
}
RKImportDialog::RKImportDialog (const QString &context_id, QWidget *parent) : KFileDialog (KUrl (), QString (), parent, format_selector=new RKImportDialogFormatSelector ()) {
RKImportDialog::RKImportDialog (const QString &context_id, QWidget *parent) : KFileDialog (QUrl (), QString (), parent, format_selector=new RKImportDialogFormatSelector ()) {
RK_TRACE (DIALOGS);
setModal (false);
......
......@@ -61,8 +61,8 @@ RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool
setFaceType (KPageDialog::Tabbed);
setModal (modal);
setCaption (i18n ("Configure Packages"));
setButtons (KDialog::Ok | KDialog::Apply | KDialog::Cancel);
setWindowTitle (i18n ("Configure Packages"));
setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
LoadUnloadWidget *luwidget = new LoadUnloadWidget (this);
addChild (luwidget, i18n ("Load / Unload R packages"));
......@@ -76,7 +76,7 @@ RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool
connect (this, SIGNAL (currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), this, SLOT (slotPageChanged()));
QTimer::singleShot (0, this, SLOT (slotPageChanged()));
num_child_widgets = 4;
accepted = false;
was_accepted = false;
RKGlobals::rInterface ()->issueCommand (".libPaths ()", RCommand::App | RCommand::GetStringVector, QString (), this, GET_CURRENT_LIBLOCS_COMMAND, chain);
}
......@@ -84,16 +84,16 @@ RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool
RKLoadLibsDialog::~RKLoadLibsDialog () {
RK_TRACE (DIALOGS);
if (accepted) KPageDialog::accept ();
if (was_accepted) KPageDialog::accept ();
else KPageDialog::reject ();
}
KPageWidgetItem* RKLoadLibsDialog::addChild (QWidget *child_page, const QString &caption) {
RK_TRACE (DIALOGS);
connect (this, SIGNAL (okClicked()), child_page, SLOT (ok()));
connect (this, SIGNAL (applyClicked()), child_page, SLOT (apply()));
connect (this, SIGNAL (cancelClicked()), child_page, SLOT (cancel()));
connect (this, SIGNAL (accepted()), child_page, SLOT (ok()));
connect (button (QDialogButtonBox::Apply), SIGNAL (clicked(bool)), child_page, SLOT (apply()));
connect (this, SIGNAL(rejected()), child_page, SLOT (cancel()));
connect (child_page, SIGNAL (destroyed()), this, SLOT (childDeleted()));
return addPage (child_page, caption);
}
......@@ -147,32 +147,26 @@ void RKLoadLibsDialog::childDeleted () {
tryDestruct ();
}
void RKLoadLibsDialog::slotButtonClicked (int button) {
RK_TRACE (DIALOGS);
switch (button) {
case KDialog::Ok:
accepted = true;
hide ();
emit (okClicked ()); // will self-destruct via childDeleted ()
break;
case KDialog::Cancel:
accepted = false;
hide ();
emit (cancelClicked ()); // will self-destruct via childDeleted ()
break;
case KDialog::Apply:
emit (applyClicked ());
break;
}
}
void RKLoadLibsDialog::closeEvent (QCloseEvent *e) {
RK_TRACE (DIALOGS);
e->accept ();
// do as if cancel button was clicked:
slotButtonClicked (KDialog::Cancel);
reject ();
}
void RKLoadLibsDialog::accept () {
was_accepted = true;
hide ();
// will self-destruct once all children are done
emit (accepted());
}
void RKLoadLibsDialog::reject () {
was_accepted = false;
hide ();
// will self-destruct once all children are done
emit (rejected());
}
void RKLoadLibsDialog::rCommandDone (RCommand *command) {
......
......@@ -66,6 +66,8 @@ public:
static void showInstallPackagesModal (QWidget *parent, RCommandChain *chain, const QString &package_name);
static void showPluginmapConfig (QWidget *parent=0, RCommandChain *chain=0);
QStringList currentLibraryLocations () const { return library_locations; };
void accept () override;
void reject () override;
signals:
void downloadComplete ();
void installationComplete ();
......@@ -78,7 +80,6 @@ protected:
void closeEvent (QCloseEvent *e);
protected slots:
/** overloaded to catch button presses. */
void slotButtonClicked (int button);
void childDeleted ();
void processExited (int exitCode, QProcess::ExitStatus exitStatus);
void installationProcessOutput ();
......@@ -102,7 +103,7 @@ friend class InstallPackagesWidget;
QString auto_install_package;
int num_child_widgets;
bool accepted;
bool was_accepted;
QProcess* installation_process;
};
......
......@@ -92,7 +92,7 @@ QString RKRecoverDialog::saveFileFor (const QString& recovery_file) {
}
//static
KUrl RKRecoverDialog::checkRecoverCrashedWorkspace () {
QUrl RKRecoverDialog::checkRecoverCrashedWorkspace () {
RK_TRACE (DIALOGS);
QDir dir (RKSettingsModuleGeneral::filesPath ());
......@@ -114,9 +114,9 @@ KUrl RKRecoverDialog::checkRecoverCrashedWorkspace () {
matches[i] = new_name;
}
if (dialog.result () == QDialog::Accepted) return (KUrl::fromLocalFile (dir.absoluteFilePath (matches.first ())));
if (dialog.result () == QDialog::Accepted) return (QUrl::fromLocalFile (dir.absoluteFilePath (matches.first ())));
}
return KUrl ();
return QUrl ();
}
......@@ -27,8 +27,8 @@ class RKRecoverDialog : public KDialog {
Q_OBJECT
public:
/** Check whether a crash recovery file is available. If so, display a dialog, offering to load the recovery file.
@returns The url of the recovery file, if user selected to load it. An empty KUrl otherwise. */
static KUrl checkRecoverCrashedWorkspace ();
@returns The url of the recovery file, if user selected to load it. An empty QUrl otherwise. */
static QUrl checkRecoverCrashedWorkspace ();
protected:
RKRecoverDialog (const QStringList &recovery_files);
~RKRecoverDialog ();
......
......@@ -31,7 +31,7 @@ SET(misc_STAT_SRCS
)
ADD_LIBRARY(misc STATIC ${misc_STAT_SRCS})
TARGET_LINK_LIBRARIES(misc Qt5::Widgets KF5::KDELibs4Support)
########### install files ###############
......
......@@ -17,7 +17,7 @@
#include "rkdummypart.h"
#include <kglobal.h>
#include <QGuiApplication>
#include "../debug.h"
......
......@@ -57,7 +57,9 @@ QAction* RKStandardActions::runCurrent (RKMDIWindow *window, const QObject *rece
ret->setText (i18n ("Run selection"));
}
ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunLine));
ret->setShortcut (KShortcut (Qt::ControlModifier + Qt::Key_Return, Qt::ControlModifier + Qt::Key_Enter));
window->standardActionCollection ()->setDefaultShortcuts (ret, QList<QKeySequence>() << Qt::ControlModifier + Qt::Key_Return << Qt::ControlModifier + Qt::Key_Enter);
ret->setShortcut (Qt::ControlModifier + Qt::Key_Return); // KF5 TODO: Not needed for KF5 >= 5.2
return ret;
}
......@@ -67,7 +69,9 @@ QAction* RKStandardActions::runAll (RKMDIWindow *window, const QObject *receiver
QAction* ret = window->standardActionCollection ()->addAction ("run_all", receiver, member);
ret->setText (i18n ("Run all"));
ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunAll));
ret->setShortcut (KShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return, Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Enter));
window->standardActionCollection ()->setDefaultShortcuts (ret, QList<QKeySequence>() << Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return << Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Enter);
ret->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Return); // KF5 TODO: Not needed for KF5 >= 5.2
return ret;
}
......
......@@ -32,7 +32,7 @@ SET(plugin_STAT_SRCS
)
ADD_LIBRARY(plugin STATIC ${plugin_STAT_SRCS})
TARGET_LINK_LIBRARIES(plugin Qt5::Widgets Qt5::Script KF5::KDELibs4Support)
TARGET_LINK_LIBRARIES(plugin Qt5::Widgets Qt5::Script KF5::TextEditor KF5::KDELibs4Support)
########### install files ###############
......
......@@ -141,7 +141,7 @@ QVariant RKMatrixInput::value (const QString& modifier) {
if (l.size () > row_count->intValue ()) l = l.mid (0, row_count->intValue ());
return l;
}
return ("Modifier '" + modifier + "' not recognized\n");
return (QString ("Modifier '" + modifier + "' not recognized\n"));
}
bool RKMatrixInput::expandStorageForColumn (int column) {
......@@ -503,7 +503,7 @@ QVariant RKMatrixInputModel::data (const QModelIndex& index, int role) const {
if ((role == Qt::DisplayRole) || (role == Qt::EditRole)) {
return QVariant (value);
} else if (role == Qt::BackgroundRole) {
if (!matrix->is_valid && !matrix->isValueValid (value)) return QVariant (Qt::red);
if (!matrix->is_valid && !matrix->isValueValid (value)) return QVariant (QColor (Qt::red));
} else if ((role == Qt::ToolTipRole) || (role == Qt::StatusTipRole)) {
if (!matrix->is_valid && (value.isEmpty () && !matrix->allow_missings)) return QVariant (i18n ("Empty values are not allowed"));
if (!matrix->is_valid && !matrix->isValueValid (value)) return QVariant (i18n ("This value is not allowed, here"));
......@@ -528,7 +528,7 @@ QVariant RKMatrixInputModel::headerData (int section, Qt::Orientation orientatio
return QVariant (QString::number (section + 1));
} else if (orientation == Qt::Horizontal) {
if (section < matrix->column_count->intValue ()) {
if ((role == Qt::BackgroundRole) && !matrix->isColumnValid (section)) return QVariant (Qt::red);
if ((role == Qt::BackgroundRole) && !matrix->isColumnValid (section)) return QVariant (QColor (Qt::red));
if (((role == Qt::ToolTipRole) || (role == Qt::StatusTipRole)) && !matrix->isColumnValid (section)) return QVariant (i18n ("This column contains illegal values in some of its cells"));
}
}
......
......@@ -823,8 +823,8 @@ QVariant RKOptionSetDisplayModel::data (const QModelIndex& index, int role) cons
}
} else if (role == Qt::BackgroundRole) {
const RKOptionSet::RowInfo &ri = set->rows[row];
if (!ri.finished) return Qt::yellow;
if (!ri.valid) return Qt::red;
if (!ri.finished) return QColor (Qt::yellow);
if (!ri.valid) return QColor (Qt::red);
} else if ((role == Qt::ToolTipRole) || role == (Qt::StatusTipRole)) {
const RKOptionSet::RowInfo &ri = set->rows[row];
if (!ri.finished) return i18n ("This row has not yet been processed.");
......@@ -844,8 +844,8 @@ QVariant RKOptionSetDisplayModel::headerData (int section, Qt::Orientation orien
if (orientation == Qt::Horizontal) {
if (role == Qt::DisplayRole) return (column_labels.value (section));
if (role == Qt::BackgroundRole) {
if (set->n_unfinished_rows > 0) return Qt::yellow;
if (!set->isValid ()) return Qt::red;
if (set->n_unfinished_rows > 0) return QColor (Qt::yellow);
if (!set->isValid ()) return QColor (Qt::red);
}
if ((role == Qt::ToolTipRole) || role == (Qt::StatusTipRole)) {
if (set->n_unfinished_rows > 0) return i18n ("Please wait while settings are being processed");
......
......@@ -12,7 +12,7 @@ SET(scriptbackends_STAT_SRCS
)
ADD_LIBRARY(scriptbackends STATIC ${scriptbackends_STAT_SRCS})
TARGET_LINK_LIBRARIES(scriptbackends Qt5::Script Qt5::Widgets Qt5::Xml KF5::KDELibs4Support)
########### install files ###############
......
......@@ -18,6 +18,8 @@
#ifndef QTSCRIPTI18N_H
#define QTSCRIPTI18N_H
#include <QObject>
#include "../misc/rkmessagecatalog.h"
class QScriptEngine;
......
......@@ -24,7 +24,7 @@ SET(windows_STAT_SRCS
)
ADD_LIBRARY(windows STATIC ${windows_STAT_SRCS})
TARGET_LINK_LIBRARIES(windows Qt5::Widgets Qt5::Xml KF5::TextEditor KF5::WebKit KF5::KDELibs4Support)
########### install files ###############
......
......@@ -18,10 +18,9 @@
#include <kxmlguifactory.h>
#include <ktexteditor/editorchooser.h>
#include <ktexteditor/editor.h>
#include <ktexteditor/modificationinterface.h>
#include <ktexteditor/markinterface.h>
#include <ktexteditor/sessionconfiginterface.h>
#include <qlayout.h>
#include <qapplication.h>
......@@ -49,6 +48,7 @@
#include <ktemporaryfile.h>
#include <kio/deletejob.h>
#include <kio/job.h>
#include <kconfiggroup.h>
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkstandardicons.h"
......@@ -85,7 +85,7 @@ RKCommandEditorWindowPart::~RKCommandEditorWindowPart () {
RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highlighting, bool use_codehinting) : RKMDIWindow (parent, RKMDIWindow::CommandEditorWindow) {
RK_TRACE (COMMANDEDITOR);
KTextEditor::Editor* editor = KTextEditor::editor("katepart");
KTextEditor::Editor* editor = KTextEditor::Editor::instance ();
RK_ASSERT (editor);
m_doc = editor->createDocument (this);
......@@ -97,7 +97,6 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highli
if (em_iface) em_iface->setModifiedOnDiskWarning (true);
else RK_ASSERT (false);
m_view = m_doc->createView (this);
m_doc->editor ()->readConfig ();
setFocusProxy (m_view);
setFocusPolicy (Qt::StrongFocus);
......@@ -164,19 +163,14 @@ RKCommandEditorWindow::~RKCommandEditorWindow () {
// NOTE: TODO: Ideally we'd only write out a changed config, but how to detect config changes?
// Alternatively, only for the last closed script window
m_doc->editor ()->writeConfig ();
// KF5 TODO: verify that the code below is no longer needed
//m_doc->editor ()->writeConfig ();
if (!url ().isEmpty ()) {
KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface*> (m_doc);
QString p_url = RKWorkplace::mainWorkplace ()->portableUrl (m_doc->url ());
if (iface) {
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptDocumentSettings %1").arg (p_url));
iface->writeSessionConfig (conf);
}
iface = qobject_cast<KTextEditor::SessionConfigInterface*> (m_view);
if (iface) {
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptViewSettings %1").arg (p_url));
iface->writeSessionConfig (conf);
}
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptDocumentSettings %1").arg (p_url));
m_doc->writeSessionConfig (conf);
KConfigGroup viewconf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptViewSettings %1").arg (p_url));
m_view->writeSessionConfig (viewconf);
}
delete hinter;
......@@ -216,7 +210,8 @@ void RKCommandEditorWindow::initializeActions (KActionCollection* ac) {
// NOTE: enter_and_submit is not currently added to the menu
QAction *action = ac->addAction ("enter_and_submit", this, SLOT (enterAndSubmit()));
action->setText (i18n ("Insert line break and run"));
action->setShortcuts (KShortcut (Qt::AltModifier + Qt::Key_Return, Qt::AltModifier + Qt::Key_Enter));
ac->setDefaultShortcuts (action, QList<QKeySequence>() << Qt::AltModifier + Qt::Key_Return << Qt::AltModifier + Qt::Key_Enter);
action->setShortcut (Qt::AltModifier + Qt::Key_Return); // KF5 TODO: This line needed only for KF5 < 5.2, according to documentation
action_help_function = RKStandardActions::functionHelp (this, this, SLOT (showHelp()));
......@@ -233,9 +228,8 @@ void RKCommandEditorWindow::initializeActions (KActionCollection* ac) {
action_setwd_to_script = ac->addAction ("setwd_to_script", this, SLOT (setWDToScript()));
action_setwd_to_script->setText (i18n ("CD to script directory"));
#if KDE_IS_VERSION(4,3,0)
action_setwd_to_script->setHelpText (i18n ("Change the working directory to the directory of this script"));
#endif
action_setwd_to_script->setStatusTip (i18n ("Change the working directory to the directory of this script"));
action_setwd_to_script->setToolTip (action_setwd_to_script->statusTip ());
action_setwd_to_script->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionCDToScript));
file_save = findAction (m_view, "file_save");
......@@ -278,7 +272,7 @@ void RKCommandEditorWindow::initBlocks () {
QColor shaded = colors[i];
shaded.setAlpha (30);
record.attribute = KTextEditor::Attribute::Ptr (new KTextEditor::Attribute ());
record.attribute->clearProperty (KTextEditor::Attribute::BackgroundFillWhitespace);
record.attribute->setBackgroundFillWhitespace (false);
record.attribute->setBackground (shaded);
QPixmap colorsquare (16, 16);
......@@ -331,7 +325,7 @@ QString RKCommandEditorWindow::fullCaption () {
if (m_doc->url ().isEmpty ()) {
return (shortCaption ());
} else {
QString cap = m_doc->url ().pathOrUrl ();
QString cap = m_doc->url ().toDisplayString (QUrl::PreferLocalFile | QUrl::PrettyDecoded);
if (isModified ()) cap.append (i18n (" [modified]"));
return (cap);
}
......@@ -362,32 +356,28 @@ void RKCommandEditorWindow::setReadOnly (bool ro) {
m_doc->setReadWrite (!ro);
}
bool RKCommandEditorWindow::openURL (const KUrl url, const QString& encoding, bool use_r_highlighting, bool read_only, bool delete_on_close){
bool RKCommandEditorWindow::openURL (const QUrl url, const QString& encoding, bool use_r_highlighting, bool read_only, bool delete_on_close){
RK_TRACE (COMMANDEDITOR);
// encoding must be set *before* loading the file
if (!encoding.isEmpty ()) m_doc->setEncoding (encoding);
if (m_doc->openUrl (url)) {
// KF5 TODO: Check which parts of this are still needed in KF5, and which no longer work
if (!delete_on_close) { // don't litter config with temporary files
KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface*> (m_doc);
QString p_url = RKWorkplace::mainWorkplace ()->portableUrl (m_doc->url ());
if (iface) {
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptDocumentSettings %1").arg (p_url));
// HACK: Hmm. KTextEditor::Document's readSessionConfig() simply restores too much. Yes, I want to load bookmarks and stuff.
// I do not want to mess with encoding, or risk loading a different url, after the doc is already loaded!
if (!encoding.isEmpty () && (conf.readEntry ("Encoding", encoding) != encoding)) conf.writeEntry ("Encoding", encoding);
if (conf.readEntry ("URL", url) != url) conf.writeEntry ("URL", url);
/* HACK: What the...?! Somehow, at least on longer R scripts, stored Mode="Normal" in combination with R Highlighting
* causes code folding to fail (KDE 4.8.4, http://sourceforge.net/p/rkward/bugs/122/).
* Forcing Mode == Highlighting appears to help. */
if (use_r_highlighting) conf.writeEntry ("Mode", conf.readEntry ("Highlighting", "Normal"));
iface->readSessionConfig (conf);
}
iface = qobject_cast<KTextEditor::SessionConfigInterface*> (m_view);
if (iface) {
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptViewSettings %1").arg (p_url));
iface->readSessionConfig (conf);
}
KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptDocumentSettings %1").arg (p_url));
// HACK: Hmm. KTextEditor::Document's readSessionConfig() simply restores too much. Yes, I want to load bookmarks and stuff.
// I do not want to mess with encoding, or risk loading a different url, after the doc is already loaded!
if (!encoding.isEmpty () && (conf.readEntry ("Encoding", encoding) != encoding)) conf.writeEntry ("Encoding", encoding);
if (conf.readEntry ("URL", url) != url) conf.writeEntry ("URL", url);
// HACK: What the...?! Somehow, at least on longer R scripts, stored Mode="Normal" in combination with R Highlighting
// causes code folding to fail (KDE 4.8.4, http://sourceforge.net/p/rkward/bugs/122/).
// Forcing Mode == Highlighting appears to help.
if (use_r_highlighting) conf.writeEntry ("Mode", conf.readEntry ("Highlighting", "Normal"));
m_doc->readSessionConfig (conf);
KConfigGroup viewconf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptViewSettings %1").arg (p_url));
m_view->readSessionConfig (viewconf);
}
if (use_r_highlighting) RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::RScript);
else RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::Automatic);
......@@ -1072,12 +1062,12 @@ void RKCodeCompletionModel::completionInvoked (KTextEditor::View*, const KTextEd
updateCompletionList (command_editor->currentCompletionWord ());
}
void RKCodeCompletionModel::executeCompletionItem (KTextEditor::Document *document, const KTextEditor::Range &word, int row) const {
void RKCodeCompletionModel::executeCompletionItem (KTextEditor::View *view, const KTextEditor::Range &word, const QModelIndex &index) const {
RK_TRACE (COMMANDEDITOR);
RK_ASSERT (names.size () > row);
RK_ASSERT (names.size () > index.row ());
document->replaceText (word, names[row]);
view->document ()->replaceText (word, names[index.row ()]);
}
QVariant RKCodeCompletionModel::data (const QModelIndex& index, int role) const {
......@@ -1108,12 +1098,12 @@ KTextEditor::Document* RKCommandHighlighter::getDoc () {
if (_doc) return _doc;
RK_TRACE (COMMANDEDITOR);
KTextEditor::Editor* editor = KTextEditor::editor("katepart");
KTextEditor::Editor* editor = KTextEditor::Editor::instance ();
RK_ASSERT (editor);
_doc = editor->createDocument (RKWardMainWindow::getMain ());
// NOTE: In KDE 4.4.5, a (dummy) view is needed to access highlighting attributes. According to a katepart error message, this will be fixed, eventually.
// TODO: check whether this is fixed in some later version of KDE
// KF5 TODO: check whether this is fixed
QWidget* view = _doc->createView (0);
view->hide ();
RK_ASSERT (_doc);
......
......@@ -146,7 +146,7 @@ public:
@param encoding encoding to use. If QString (), the default encoding is used.
@param read_only Open the file in read-only mode
@param delete_on_close File should be deleted when closing the window. Only respected with read_only=true. */
bool openURL (const KUrl url, const QString& encoding=QString (), bool use_r_highlighting=true, bool read_only=false, bool delete_on_close=false);
bool openURL (const QUrl url, const QString& encoding=QString (), bool use_r_highlighting=true, bool read_only=false, bool delete_on_close=false);
/** returns, whether the document was modified since the last save */
bool isModified ();
/** insert the given text into the document at the current cursor position. Additionally, focuses the view */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment