Changeset View
Changeset View
Standalone View
Standalone View
krusader/Synchronizer/synchronizergui.h
Show All 18 Lines | |||||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | 20 | | |||
21 | #ifndef SYNCHRONIZERGUI_H | 21 | #ifndef SYNCHRONIZERGUI_H | ||
22 | #define SYNCHRONIZERGUI_H | 22 | #define SYNCHRONIZERGUI_H | ||
23 | 23 | | |||
24 | // QtCore | 24 | // QtCore | ||
25 | #include <QMap> | 25 | #include <QMap> | ||
26 | // QtGui | 26 | // QtGui | ||
27 | #include <QResizeEvent> | | |||
28 | #include <QKeyEvent> | 27 | #include <QKeyEvent> | ||
29 | #include <QPixmap> | 28 | #include <QPixmap> | ||
29 | #include <QResizeEvent> | ||||
30 | // QtWidgets | 30 | // QtWidgets | ||
31 | #include <QCheckBox> | 31 | #include <QCheckBox> | ||
32 | #include <QDialog> | 32 | #include <QDialog> | ||
33 | #include <QLabel> | 33 | #include <QLabel> | ||
34 | #include <QSpinBox> | ||||
34 | #include <QTabWidget> | 35 | #include <QTabWidget> | ||
36 | #include <QTreeWidget> | ||||
35 | 37 | | |||
36 | #include <KCompletion/KComboBox> | 38 | #include <KCompletion/KComboBox> | ||
39 | #include <KCompletion/KHistoryComboBox> | ||||
37 | 40 | | |||
38 | #include "synchronizer.h" | 41 | #include "synchronizer.h" | ||
39 | #include "../GUI/profilemanager.h" | | |||
40 | #include "../GUI/krtreewidget.h" | | |||
41 | #include "../Filter/filtertabs.h" | | |||
42 | #include "../Filter/generalfilter.h" | | |||
43 | 42 | | |||
44 | class QSpinBox; | 43 | class FilterTabs; | ||
44 | class GeneralFilter; | ||||
45 | class KrTreeWidget; | ||||
46 | class ProfileManager; | ||||
45 | 47 | | |||
46 | class SynchronizerGUI : public QDialog | | |||
47 | { | | |||
48 | Q_OBJECT | | |||
49 | | ||||
50 | public: | | |||
51 | class SyncViewItem : public QTreeWidgetItem | 48 | class SyncViewItem : public QTreeWidgetItem | ||
52 | { | 49 | { | ||
53 | private: | 50 | private: | ||
54 | SynchronizerFileItem *syncItemRef; | 51 | SynchronizerFileItem *syncItemRef; | ||
55 | SyncViewItem *lastItemRef; | 52 | SyncViewItem *lastItemRef; | ||
56 | 53 | | |||
57 | public: | 54 | public: | ||
58 | SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidget * parent, QTreeWidgetItem *after, QString label1, | 55 | SyncViewItem(SynchronizerFileItem *item, const QColor &txt, const QColor &base, | ||
59 | QString label2 = QString(), QString label3 = QString(), QString label4 = QString(), | 56 | QTreeWidget *parent, QTreeWidgetItem *after, const QString &label1, | ||
60 | QString label5 = QString(), QString label6 = QString(), | 57 | const QString &label2, const QString &label3, const QString &label4, | ||
61 | QString label7 = QString(), QString label8 = QString()) : | 58 | const QString &label5, const QString &label6, const QString &label7); | ||
62 | QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) { | 59 | | ||
63 | setText(0, label1); | 60 | SyncViewItem(SynchronizerFileItem *item, const QColor &txt, const QColor &base, | ||
64 | setText(1, label2); | 61 | QTreeWidgetItem *parent, QTreeWidgetItem *after, const QString &label1, | ||
65 | setText(2, label3); | 62 | const QString &label2, const QString &label3, const QString &label4, | ||
66 | setText(3, label4); | 63 | const QString &label5, const QString &label6, const QString &label7); | ||
67 | setText(4, label5); | 64 | | ||
68 | setText(5, label6); | 65 | ~SyncViewItem() { syncItemRef->setViewItem(nullptr); } | ||
69 | setText(6, label7); | 66 | | ||
70 | setText(7, label8); | 67 | inline SynchronizerFileItem *synchronizerItemRef() { return syncItemRef; } | ||
71 | 68 | inline SyncViewItem *lastItem() { return lastItemRef; } | |||
72 | setTextAlignment(1, Qt::AlignRight); | 69 | inline void setLastItem(SyncViewItem *s) { lastItemRef = s; } | ||
73 | setTextAlignment(3, Qt::AlignHCenter); | 70 | | ||
74 | setTextAlignment(5, Qt::AlignRight); | 71 | void setColors(const QColor &fore, const QColor &back); | ||
75 | item->setUserData((void *)this); | 72 | | ||
76 | 73 | private: | |||
77 | setColors(txt, base); | 74 | void setColumns(const QString &label1, const QString &label2, const QString &label3, | ||
78 | } | 75 | const QString &label4, const QString &label5, const QString &label6, | ||
79 | 76 | const QString &label7, SynchronizerFileItem *item, const QColor &txt, | |||
80 | SyncViewItem(SynchronizerFileItem *item, QColor txt, QColor base, QTreeWidgetItem * parent, QTreeWidgetItem *after, QString label1, | 77 | const QColor &base); | ||
81 | QString label2 = QString(), QString label3 = QString(), QString label4 = QString(), | | |||
82 | QString label5 = QString(), QString label6 = QString(), | | |||
83 | QString label7 = QString(), QString label8 = QString()) : | | |||
84 | QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) { | | |||
85 | setText(0, label1); | | |||
86 | setText(1, label2); | | |||
87 | setText(2, label3); | | |||
88 | setText(3, label4); | | |||
89 | setText(4, label5); | | |||
90 | setText(5, label6); | | |||
91 | setText(6, label7); | | |||
92 | setText(7, label8); | | |||
93 | | ||||
94 | setTextAlignment(1, Qt::AlignRight); | | |||
95 | setTextAlignment(3, Qt::AlignHCenter); | | |||
96 | setTextAlignment(5, Qt::AlignRight); | | |||
97 | item->setUserData((void *)this); | | |||
98 | | ||||
99 | setColors(txt, base); | | |||
100 | } | | |||
101 | | ||||
102 | ~SyncViewItem() { | | |||
103 | syncItemRef->setUserData(0); | | |||
104 | } | | |||
105 | | ||||
106 | inline SynchronizerFileItem * synchronizerItemRef() { | | |||
107 | return syncItemRef; | | |||
108 | } | | |||
109 | inline SyncViewItem * lastItem() { | | |||
110 | return lastItemRef; | | |||
111 | } | | |||
112 | inline void setLastItem(SyncViewItem*s) { | | |||
113 | lastItemRef = s; | | |||
114 | } | | |||
115 | | ||||
116 | void setColors(QColor fore, QColor back) { | | |||
117 | QBrush textColor(fore); | | |||
118 | QBrush baseColor(back); | | |||
119 | | ||||
120 | for (int i = 0; i != columnCount(); i++) { | | |||
121 | if (back.isValid()) | | |||
122 | setBackground(i, baseColor); | | |||
123 | if (fore.isValid()) | | |||
124 | setForeground(i, textColor); | | |||
125 | } | | |||
126 | } | | |||
127 | }; | 78 | }; | ||
128 | 79 | | |||
80 | class SynchronizerGUI : public QDialog | ||||
81 | { | ||||
82 | Q_OBJECT | ||||
83 | | ||||
129 | public: | 84 | public: | ||
130 | // if rightDirectory is null, leftDirectory is actually the profile name to load | 85 | // if rightDirectory is null, leftDirectory is actually the profile name to load | ||
131 | SynchronizerGUI(QWidget* parent, QUrl leftDirectory, QUrl rightDirectory = QUrl(), QStringList selList = QStringList()); | 86 | SynchronizerGUI(QWidget *parent, QUrl leftDirectory, QUrl rightDirectory = QUrl(), | ||
87 | QStringList selList = QStringList()); | ||||
132 | SynchronizerGUI(QWidget* parent, QString profile); | 88 | SynchronizerGUI(QWidget *parent, QString profile); | ||
133 | ~SynchronizerGUI(); | 89 | ~SynchronizerGUI(); | ||
134 | 90 | | |||
135 | inline bool wasSynchronization() { | 91 | inline bool wasSynchronization() { return wasSync; } | ||
136 | return wasSync; | | |||
137 | } | | |||
138 | 92 | | |||
139 | public slots: | 93 | public slots: | ||
140 | void rightMouseClicked(QTreeWidgetItem *, const QPoint &); | 94 | void rightMouseClicked(QTreeWidgetItem *, const QPoint &); | ||
141 | void doubleClicked(QTreeWidgetItem *); | 95 | void doubleClicked(QTreeWidgetItem *); | ||
142 | void compare(); | 96 | void compare(); | ||
143 | void synchronize(); | 97 | void synchronize(); | ||
144 | void stop(); | 98 | void stop(); | ||
145 | void feedToListBox(); | 99 | void feedToListBox(); | ||
Show All 14 Lines | 106 | protected slots: | |||
160 | void setCompletion(); | 114 | void setCompletion(); | ||
161 | void checkExcludeURLValidity(QString &text, QString &error); | 115 | void checkExcludeURLValidity(QString &text, QString &error); | ||
162 | void connectFilters(const QString &); | 116 | void connectFilters(const QString &); | ||
163 | 117 | | |||
164 | private: | 118 | private: | ||
165 | void initGUI(QString profile, QUrl leftURL, QUrl rightURL, QStringList selList); | 119 | void initGUI(QString profile, QUrl leftURL, QUrl rightURL, QStringList selList); | ||
166 | 120 | | |||
167 | QString convertTime(time_t time) const; | 121 | QString convertTime(time_t time) const; | ||
168 | void setMarkFlags(); | 122 | void setMarkFlags(); | ||
169 | void disableMarkButtons(); | 123 | void disableMarkButtons(); | ||
170 | void enableMarkButtons(); | 124 | void enableMarkButtons(); | ||
171 | void copyToClipboard(bool isLeft); | 125 | void copyToClipboard(bool isLeft); | ||
172 | 126 | | |||
173 | int convertToSeconds(int time, int unit); | 127 | int convertToSeconds(int time, int unit); | ||
174 | void convertFromSeconds(int &time, int &unit, int second); | 128 | void convertFromSeconds(int &time, int &unit, int second); | ||
175 | 129 | | |||
176 | static QPushButton *createButton(QWidget *parent, const QString &iconName, bool checked, | 130 | static QPushButton *createButton(QWidget *parent, const QString &iconName, bool checked, | ||
177 | const QKeySequence &shortCut, const QString &description, | 131 | const QKeySequence &shortCut, const QString &description, | ||
178 | const QString &text = QString(), bool textAndIcon = false); | 132 | const QString &text = QString(), bool textAndIcon = false); | ||
179 | 133 | | |||
180 | protected: | 134 | protected: | ||
181 | virtual void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; | 135 | virtual void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; | ||
182 | virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; | 136 | virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
229 | QSpinBox *equalitySpinBox; | 183 | QSpinBox *equalitySpinBox; | ||
230 | QComboBox *equalityUnitCombo; | 184 | QComboBox *equalityUnitCombo; | ||
231 | QSpinBox *timeShiftSpinBox; | 185 | QSpinBox *timeShiftSpinBox; | ||
232 | QComboBox *timeShiftUnitCombo; | 186 | QComboBox *timeShiftUnitCombo; | ||
233 | QCheckBox *ignoreHiddenFilesCB; | 187 | QCheckBox *ignoreHiddenFilesCB; | ||
234 | 188 | | |||
235 | private: | 189 | private: | ||
236 | static QString dirLabel(); // returns translated '<DIR>' | 190 | static QString dirLabel(); // returns translated '<DIR>' | ||
191 | static KHistoryComboBox *createHistoryComboBox(QWidget *parent, bool enabled); | ||||
192 | static QUrl getUrl(KHistoryComboBox *location); | ||||
237 | 193 | | |||
238 | bool isComparing; | 194 | bool isComparing; | ||
239 | bool wasClosed; | 195 | bool wasClosed; | ||
240 | bool wasSync; | 196 | bool wasSync; | ||
241 | bool firstResize; | 197 | bool firstResize; | ||
242 | bool hasSelectedFiles; | 198 | bool hasSelectedFiles; | ||
243 | SyncViewItem *lastItem; | 199 | SyncViewItem *lastItem; | ||
244 | 200 | | |||
245 | int sizeX; | 201 | int sizeX; | ||
246 | int sizeY; | 202 | int sizeY; | ||
247 | 203 | | |||
248 | QColor foreGrounds[ TT_MAX ]; | 204 | QColor foreGrounds[ TT_MAX ]; | ||
249 | QColor backGrounds[ TT_MAX ]; | 205 | QColor backGrounds[ TT_MAX ]; | ||
250 | }; | 206 | }; | ||
251 | 207 | | |||
252 | #endif /* __SYNCHRONIZERGUI_H__ */ | 208 | #endif /* __SYNCHRONIZERGUI_H__ */ |