1 /* 2 This file is part of Lokalize 3 4 SPDX-FileCopyrightText: 2007-2009 Nick Shaforostoff <shafff@ukr.net> 5 SPDX-FileCopyrightText: 2018-2019 Simon Depiets <sdepiets@gmail.com> 6 7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 8 */ 9 10 #ifndef EDITORVIEW_H 11 #define EDITORVIEW_H 12 13 #include "pos.h" 14 #include "state.h" 15 #include "catalogstring.h" 16 17 #include <QSplitter> 18 19 class Catalog; 20 class LedsWidget; 21 class TranslationUnitTextEdit; 22 class QTabBar; 23 class QContextMenuEvent; 24 class QDragEnterEvent; 25 26 /** 27 * This is the main view class for Lokalize Editor. 28 * Most of the non-menu, non-toolbar, non-statusbar, 29 * and non-dockview editing GUI code should go here. 30 * 31 * There are several ways (for views) to modify current msg: 32 * -modify KTextEdit and changes will be applied to catalog automatically (plus you need to care of fuzzy indication etc) 33 * -modify catalog directly, then call EditorWindow::gotoEntry slot 34 * I used both :) 35 * 36 * @short Main editor view: source and target textedits 37 * @author Nick Shaforostoff <shafff@ukr.net> 38 */ 39 40 class EditorView: public QSplitter 41 { 42 Q_OBJECT 43 public: 44 explicit EditorView(QWidget *, Catalog*); 45 virtual ~EditorView(); 46 tabBar()47 QTabBar* tabBar() 48 { 49 return m_pluralTabBar; //to connect tabbar signals to controller (EditorWindow) slots 50 } 51 QString selectionInTarget() const;//for non-batch replace 52 QString selectionInSource() const; 53 54 QObject* viewPort(); 55 void setProperFocus(); 56 57 public Q_SLOTS: 58 void gotoEntry(DocPosition pos, int selection/*, bool updateHistory=true*/); 59 void gotoEntry(); 60 void toggleApprovement(); 61 void setState(TargetState); 62 void setEquivTrans(bool); 63 void settingsChanged(); 64 void insertTerm(const QString&); 65 //workaround for qt ctrl+z bug 66 //Edit menu 67 void unwrap(); 68 void unwrap(TranslationUnitTextEdit* editor); 69 70 /* 71 void dragEnterEvent(QDragEnterEvent* event); 72 void dropEvent(QDropEvent*); 73 */ 74 private: 75 Catalog* m_catalog; 76 77 TranslationUnitTextEdit * m_sourceTextEdit; 78 TranslationUnitTextEdit * m_targetTextEdit 79 ; 80 81 QTabBar* m_pluralTabBar; 82 LedsWidget* m_leds; 83 84 public: 85 bool m_modifiedAfterFind;//for F3-search reset 86 87 Q_SIGNALS: 88 void signalEquivTranslatedEntryDisplayed(bool); 89 void signalApprovedEntryDisplayed(bool); 90 void signalChangeStatusbar(const QString&); 91 void signalChanged(uint index); //esp for mergemode... 92 void binaryUnitSelectRequested(const QString& id); 93 void gotoEntryRequested(const DocPosition&); 94 void tmLookupRequested(DocPosition::Part, const QString&); 95 //void tmLookupRequested(const QString& source, const QString& target); 96 void findRequested(); 97 void findNextRequested(); 98 void replaceRequested(); 99 void doExplicitCompletion(); 100 101 private Q_SLOTS: 102 void resetFindForCurrent(const DocPosition& pos); 103 void toggleBookmark(bool); 104 }; 105 106 107 class KLed; 108 class QLabel; 109 class LedsWidget: public QWidget 110 { 111 Q_OBJECT 112 public: 113 explicit LedsWidget(QWidget* parent); 114 private: 115 void contextMenuEvent(QContextMenuEvent* event) override; 116 117 public Q_SLOTS: 118 void cursorPositionChanged(int column); 119 120 public: 121 KLed* ledFuzzy; 122 KLed* ledUntr; 123 QLabel* lblColumn; 124 }; 125 126 #endif 127