Changeset View
Changeset View
Standalone View
Standalone View
krusader/Synchronizer/synchronizergui.cpp
Show All 13 Lines | |||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
15 | * GNU General Public License for more details. * | 15 | * GNU General Public License for more details. * | ||
16 | * * | 16 | * * | ||
17 | * You should have received a copy of the GNU General Public License * | 17 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | 20 | | |||
21 | #include "synchronizergui.h" | 21 | #include "synchronizergui.h" | ||
22 | #include "../krglobal.h" | 22 | | ||
23 | #include "../filelisticon.h" | 23 | #include "feedtolistboxdialog.h" | ||
24 | #include "../defaults.h" | 24 | #include "synchronizedialog.h" | ||
25 | #include "../krusaderview.h" | 25 | #include "synchronizercolors.h" | ||
26 | #include "../Panel/listpanel.h" | | |||
27 | #include "../Panel/panelfunc.h" | | |||
28 | #include "../FileSystem/krpermhandler.h" | | |||
29 | #include "../KViewer/krviewer.h" | | |||
30 | #include "../Dialogs/krspwidgets.h" | 26 | #include "../Dialogs/krspwidgets.h" | ||
27 | #include "../FileSystem/krpermhandler.h" | ||||
31 | #include "../FileSystem/krquery.h" | 28 | #include "../FileSystem/krquery.h" | ||
29 | #include "../Filter/filtertabs.h" | ||||
30 | #include "../Filter/generalfilter.h" | ||||
31 | #include "../GUI/krtreewidget.h" | ||||
32 | #include "../GUI/profilemanager.h" | ||||
33 | #include "../KViewer/krviewer.h" | ||||
34 | #include "../Panel/listpanel.h" | ||||
35 | #include "../Panel/panelfunc.h" | ||||
36 | #include "../defaults.h" | ||||
37 | #include "../filelisticon.h" | ||||
38 | #include "../icon.h" | ||||
39 | #include "../krglobal.h" | ||||
32 | #include "../krservices.h" | 40 | #include "../krservices.h" | ||
33 | #include "../krslots.h" | 41 | #include "../krslots.h" | ||
34 | #include "synchronizedialog.h" | 42 | #include "../krusaderview.h" | ||
35 | #include "feedtolistboxdialog.h" | | |||
36 | #include "synchronizercolors.h" | | |||
37 | 43 | | |||
38 | // QtCore | 44 | // QtCore | ||
39 | #include <QEventLoop> | 45 | #include <QEventLoop> | ||
40 | #include <QRegExp> | | |||
41 | #include <QMimeData> | | |||
42 | #include <QHash> | 46 | #include <QHash> | ||
47 | #include <QMimeData> | ||||
48 | #include <QRegExp> | ||||
43 | // QtGui | 49 | // QtGui | ||
44 | #include <QResizeEvent> | 50 | #include <QClipboard> | ||
51 | #include <QCursor> | ||||
52 | #include <QDrag> | ||||
45 | #include <QKeyEvent> | 53 | #include <QKeyEvent> | ||
46 | #include <QMouseEvent> | 54 | #include <QMouseEvent> | ||
47 | #include <QPixmap> | 55 | #include <QPixmap> | ||
48 | #include <QCursor> | 56 | #include <QResizeEvent> | ||
49 | #include <QDrag> | | |||
50 | #include <QClipboard> | | |||
51 | // QtWidgets | 57 | // QtWidgets | ||
52 | #include <QApplication> | 58 | #include <QApplication> | ||
53 | #include <QLabel> | 59 | #include <QFrame> | ||
54 | #include <QGridLayout> | 60 | #include <QGridLayout> | ||
55 | #include <QLayout> | | |||
56 | #include <QGroupBox> | 61 | #include <QGroupBox> | ||
57 | #include <QHBoxLayout> | 62 | #include <QHBoxLayout> | ||
58 | #include <QFrame> | | |||
59 | #include <QHeaderView> | 63 | #include <QHeaderView> | ||
64 | #include <QLabel> | ||||
65 | #include <QLayout> | ||||
60 | #include <QMenu> | 66 | #include <QMenu> | ||
61 | #include <QSpinBox> | 67 | #include <QSpinBox> | ||
62 | 68 | | |||
63 | #include <KConfigCore/KSharedConfig> | 69 | #include <KConfigCore/KSharedConfig> | ||
64 | #include <KI18n/KLocalizedString> | 70 | #include <KI18n/KLocalizedString> | ||
65 | #include <KWidgetsAddons/KMessageBox> | 71 | #include <KWidgetsAddons/KMessageBox> | ||
66 | #include <KIOWidgets/KUrlRequester> | 72 | #include <KIOWidgets/KUrlRequester> | ||
67 | #include <KGuiAddons/KColorUtils> | 73 | #include <KGuiAddons/KColorUtils> | ||
68 | 74 | | |||
75 | SyncViewItem::SyncViewItem(SynchronizerFileItem *item, const QColor &txt, const QColor &base, | ||||
76 | QTreeWidget *parent, QTreeWidgetItem *after, const QString &label1, | ||||
77 | const QString &label2, const QString &label3, const QString &label4, | ||||
78 | const QString &label5, const QString &label6, const QString &label7) | ||||
79 | : QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) | ||||
80 | { | ||||
81 | setColumns(label1, label2, label3, label4, label5, label6, label7, item, txt, base); | ||||
82 | } | ||||
83 | | ||||
84 | SyncViewItem::SyncViewItem(SynchronizerFileItem *item, const QColor &txt, const QColor &base, | ||||
85 | QTreeWidgetItem *parent, QTreeWidgetItem *after, const QString &label1, | ||||
86 | const QString &label2, const QString &label3, const QString &label4, | ||||
87 | const QString &label5, const QString &label6, const QString &label7) | ||||
88 | : QTreeWidgetItem(parent, after), syncItemRef(item), lastItemRef(0) | ||||
89 | { | ||||
90 | setColumns(label1, label2, label3, label4, label5, label6, label7, item, txt, base); | ||||
91 | } | ||||
92 | | ||||
93 | void SyncViewItem::setColumns(const QString &label1, const QString &label2, const QString &label3, | ||||
94 | const QString &label4, const QString &label5, const QString &label6, | ||||
95 | const QString &label7, SynchronizerFileItem *item, const QColor &txt, | ||||
96 | const QColor &base) | ||||
97 | { | ||||
98 | setText(0, label1); | ||||
99 | setText(1, label2); | ||||
100 | setText(2, label3); | ||||
101 | setText(3, label4); | ||||
102 | setText(4, label5); | ||||
103 | setText(5, label6); | ||||
104 | setText(6, label7); | ||||
105 | | ||||
106 | setTextAlignment(1, Qt::AlignRight); | ||||
107 | setTextAlignment(3, Qt::AlignHCenter); | ||||
108 | setTextAlignment(5, Qt::AlignRight); | ||||
109 | item->setViewItem(this); | ||||
110 | | ||||
111 | setColors(txt, base); | ||||
112 | } | ||||
113 | | ||||
114 | void SyncViewItem::setColors(const QColor &fore, const QColor &back) | ||||
115 | { | ||||
116 | QBrush textColor(fore); | ||||
117 | QBrush baseColor(back); | ||||
118 | | ||||
119 | for (int i = 0; i != columnCount(); i++) { | ||||
120 | if (back.isValid()) | ||||
121 | setBackground(i, baseColor); | ||||
122 | if (fore.isValid()) | ||||
123 | setForeground(i, textColor); | ||||
124 | } | ||||
125 | } | ||||
126 | | ||||
69 | 127 | | |||
70 | class SynchronizerListView : public KrTreeWidget | 128 | class SynchronizerListView : public KrTreeWidget | ||
71 | { | 129 | { | ||
72 | private: | 130 | private: | ||
73 | Synchronizer *synchronizer; | 131 | Synchronizer *synchronizer; | ||
74 | bool isLeft; | 132 | bool isLeft; | ||
75 | 133 | | |||
76 | public: | 134 | public: | ||
77 | SynchronizerListView(Synchronizer * sync, QWidget * parent) : KrTreeWidget(parent), synchronizer(sync) { | 135 | SynchronizerListView(Synchronizer * sync, QWidget * parent) : KrTreeWidget(parent), synchronizer(sync) { | ||
78 | } | 136 | } | ||
79 | 137 | | |||
80 | void mouseMoveEvent(QMouseEvent * e) { | 138 | void mouseMoveEvent(QMouseEvent * e) { | ||
81 | isLeft = ((e->modifiers() & Qt::ShiftModifier) == 0); | 139 | isLeft = ((e->modifiers() & Qt::ShiftModifier) == 0); | ||
82 | KrTreeWidget::mouseMoveEvent(e); | 140 | KrTreeWidget::mouseMoveEvent(e); | ||
83 | } | 141 | } | ||
84 | 142 | | |||
85 | void startDrag(Qt::DropActions /* supportedActs */) { | 143 | void startDrag(Qt::DropActions /* supportedActs */) { | ||
86 | QList<QUrl> urls; | 144 | QList<QUrl> urls; | ||
87 | 145 | | |||
88 | unsigned ndx = 0; | 146 | unsigned ndx = 0; | ||
89 | SynchronizerFileItem *currentItem; | 147 | SynchronizerFileItem *currentItem; | ||
90 | 148 | | |||
91 | while ((currentItem = synchronizer->getItemAt(ndx++)) != 0) { | 149 | while ((currentItem = synchronizer->getItemAt(ndx++)) != 0) { | ||
92 | SynchronizerGUI::SyncViewItem *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); | 150 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->viewItem(); | ||
93 | 151 | | |||
94 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | 152 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | ||
95 | continue; | 153 | continue; | ||
96 | 154 | | |||
97 | SynchronizerFileItem *item = viewItem->synchronizerItemRef(); | 155 | SynchronizerFileItem *item = viewItem->synchronizerItemRef(); | ||
98 | if (item) { | 156 | if (item) { | ||
99 | if (isLeft && item->existsInLeft()) { | 157 | if (isLeft && item->existsLeft()) { | ||
100 | QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; | 158 | const QUrl leftURL = Synchronizer::pathAppend( | ||
101 | QUrl leftURL = Synchronizer::fsUrl(synchronizer->leftBaseDirectory() + leftDirName + item->leftName()); | 159 | synchronizer->leftBaseDirectory(), item->leftDirectory(), item->leftName()); | ||
102 | urls.push_back(leftURL); | 160 | urls.push_back(leftURL); | ||
103 | } else if (!isLeft && item->existsInRight()) { | 161 | } else if (!isLeft && item->existsRight()) { | ||
104 | QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; | 162 | const QUrl rightURL = Synchronizer::pathAppend( | ||
105 | QUrl rightURL = Synchronizer::fsUrl(synchronizer->rightBaseDirectory() + rightDirName + item->rightName()); | 163 | synchronizer->rightBaseDirectory(), item->rightDirectory(), item->rightName()); | ||
106 | urls.push_back(rightURL); | 164 | urls.push_back(rightURL); | ||
107 | } | 165 | } | ||
108 | } | 166 | } | ||
109 | } | 167 | } | ||
110 | 168 | | |||
111 | if (urls.count() == 0) | 169 | if (urls.count() == 0) | ||
112 | return; | 170 | return; | ||
113 | 171 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 195 | { | |||
160 | 218 | | |||
161 | /* ============================== Compare groupbox ============================== */ | 219 | /* ============================== Compare groupbox ============================== */ | ||
162 | 220 | | |||
163 | QWidget *synchronizerTab = new QWidget(this); | 221 | QWidget *synchronizerTab = new QWidget(this); | ||
164 | QGridLayout *synchronizerGrid = new QGridLayout(synchronizerTab); | 222 | QGridLayout *synchronizerGrid = new QGridLayout(synchronizerTab); | ||
165 | synchronizerGrid->setSpacing(6); | 223 | synchronizerGrid->setSpacing(6); | ||
166 | synchronizerGrid->setContentsMargins(11, 11, 11, 11); | 224 | synchronizerGrid->setContentsMargins(11, 11, 11, 11); | ||
167 | 225 | | |||
168 | QGroupBox *compareDirs = new QGroupBox(synchronizerTab); | 226 | QGroupBox *compareGroupBox = new QGroupBox(synchronizerTab); | ||
169 | compareDirs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | 227 | compareGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||
170 | compareDirs->setTitle(i18n("Folder Comparison")); | 228 | compareGroupBox->setTitle(i18n("Folder Comparison")); | ||
171 | 229 | | |||
172 | QGridLayout *grid = new QGridLayout(compareDirs); | 230 | QGridLayout *grid = new QGridLayout(compareGroupBox); | ||
173 | grid->setSpacing(6); | 231 | grid->setSpacing(6); | ||
174 | grid->setContentsMargins(11, 11, 11, 11); | 232 | grid->setContentsMargins(11, 11, 11, 11); | ||
175 | 233 | | |||
176 | leftDirLabel = new QLabel(compareDirs); | 234 | leftDirLabel = new QLabel(compareGroupBox); | ||
177 | leftDirLabel->setAlignment(Qt::AlignHCenter); | 235 | leftDirLabel->setAlignment(Qt::AlignHCenter); | ||
178 | grid->addWidget(leftDirLabel, 0 , 0); | 236 | grid->addWidget(leftDirLabel, 0 , 0); | ||
179 | 237 | | |||
180 | QLabel *filterLabel = new QLabel(compareDirs); | 238 | QLabel *filterLabel = new QLabel(compareGroupBox); | ||
181 | filterLabel->setText(i18n("File &Filter:")); | 239 | filterLabel->setText(i18n("File &Filter:")); | ||
182 | filterLabel->setAlignment(Qt::AlignHCenter); | 240 | filterLabel->setAlignment(Qt::AlignHCenter); | ||
183 | grid->addWidget(filterLabel, 0 , 1); | 241 | grid->addWidget(filterLabel, 0 , 1); | ||
184 | 242 | | |||
185 | rightDirLabel = new QLabel(compareDirs); | 243 | rightDirLabel = new QLabel(compareGroupBox); | ||
186 | rightDirLabel->setAlignment(Qt::AlignHCenter); | 244 | rightDirLabel->setAlignment(Qt::AlignHCenter); | ||
187 | grid->addWidget(rightDirLabel, 0 , 2); | 245 | grid->addWidget(rightDirLabel, 0 , 2); | ||
188 | 246 | | |||
189 | KConfigGroup group(krConfig, "Synchronize"); | 247 | KConfigGroup group(krConfig, "Synchronize"); | ||
190 | 248 | | |||
191 | leftLocation = new KHistoryComboBox(false, compareDirs); | 249 | leftLocation = createHistoryComboBox(compareGroupBox, !hasSelectedFiles); | ||
192 | leftLocation->setMaxCount(25); // remember 25 items | 250 | leftLocation->setHistoryItems(group.readEntry("Left Folder History", QStringList())); | ||
193 | leftLocation->setDuplicatesEnabled(false); | 251 | leftLocation->setWhatsThis(i18n("The left base folder used during the synchronization process.")); | ||
194 | leftLocation->setEditable(true); | 252 | leftDirLabel->setBuddy(leftLocation); | ||
195 | leftLocation->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | 253 | KUrlRequester *leftUrlReq = new KUrlRequester(leftLocation, compareGroupBox); | ||
196 | QStringList list = group.readEntry("Left Folder History", QStringList()); | | |||
197 | leftLocation->setHistoryItems(list); | | |||
198 | KUrlRequester *leftUrlReq = new KUrlRequester(leftLocation, compareDirs); | | |||
199 | leftUrlReq->setUrl(leftURL); | 254 | leftUrlReq->setUrl(leftURL); | ||
200 | leftUrlReq->setMode(KFile::Directory); | 255 | leftUrlReq->setMode(KFile::Directory); | ||
201 | leftUrlReq->setMinimumWidth(250); | 256 | leftUrlReq->setMinimumWidth(250); | ||
202 | grid->addWidget(leftUrlReq, 1 , 0); | | |||
203 | leftLocation->setWhatsThis(i18n("The left base folder used during the synchronization process.")); | | |||
204 | leftUrlReq->setEnabled(!hasSelectedFiles); | 257 | leftUrlReq->setEnabled(!hasSelectedFiles); | ||
205 | leftLocation->setEnabled(!hasSelectedFiles); | 258 | grid->addWidget(leftUrlReq, 1 , 0); | ||
206 | leftDirLabel->setBuddy(leftLocation); | | |||
207 | 259 | | |||
208 | fileFilter = new KHistoryComboBox(false, compareDirs); | 260 | fileFilter = new KHistoryComboBox(false, compareGroupBox); | ||
209 | fileFilter->setMaxCount(25); // remember 25 items | 261 | fileFilter->setMaxCount(25); // remember 25 items | ||
210 | fileFilter->setDuplicatesEnabled(false); | 262 | fileFilter->setDuplicatesEnabled(false); | ||
211 | fileFilter->setMinimumWidth(100); | 263 | fileFilter->setMinimumWidth(100); | ||
212 | fileFilter->setMaximumWidth(100); | 264 | fileFilter->setMaximumWidth(100); | ||
213 | fileFilter->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 265 | fileFilter->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
214 | list = group.readEntry("File Filter", QStringList()); | 266 | fileFilter->setHistoryItems(group.readEntry("File Filter", QStringList())); | ||
215 | fileFilter->setHistoryItems(list); | | |||
216 | fileFilter->setEditText("*"); | 267 | fileFilter->setEditText("*"); | ||
217 | grid->addWidget(fileFilter, 1 , 1); | 268 | grid->addWidget(fileFilter, 1 , 1); | ||
218 | filterLabel->setBuddy(fileFilter); | 269 | filterLabel->setBuddy(fileFilter); | ||
219 | 270 | | |||
220 | QString wtFilter = "<p><img src='toolbar|find'></p>" + i18n("<p>The filename filtering criteria is defined here.</p><p>You can make use of wildcards. Multiple patterns are separated by space (means logical OR) and patterns are excluded from the search using the pipe symbol.</p><p>If the pattern is ended with a slash (<code>*pattern*/</code>), that means that pattern relates to recursive search of folders.<ul><li><code>pattern</code> - means to search those files/folders that name is <code>pattern</code>, recursive search goes through all subfolders independently of the value of <code>pattern</code></li><li><code>pattern/</code> - means to search all files/folders, but recursive search goes through/excludes the folders that name is <code>pattern</code></li></ul></p><p>It is allowed to use quotation marks for names that contain space. Filter <code>\"Program Files\"</code> searches out those files/folders that name is <code>Program Files</code>.</p><p>Examples:</p><ul><li><code>*.o</code></li><li><code>*.h *.c\?\?</code></li><li><code>*.cpp *.h | *.moc.cpp</code></li><li><code>* | .svn/ .git/</code></li></ul><p><b>Note</b>: the search term '<code>text</code>' is equivalent to '<code>*text*</code>'.</p>"); | 271 | const QString wtFilter = | ||
272 | "<p><img src='toolbar|find'></p>" + | ||||
273 | i18n("<p>The filename filtering criteria is defined here.</p><p>You can make use of " | ||||
274 | "wildcards. Multiple patterns are separated by space (means logical OR) and patterns " | ||||
275 | "are excluded from the search using the pipe symbol.</p><p>If the pattern is ended " | ||||
276 | "with a slash (<code>*pattern*/</code>), that means that pattern relates to recursive " | ||||
277 | "search of folders.<ul><li><code>pattern</code> - means to search those files/folders " | ||||
278 | "that name is <code>pattern</code>, recursive search goes through all subfolders " | ||||
279 | "independently of the value of <code>pattern</code></li><li><code>pattern/</code> - " | ||||
280 | "means to search all files/folders, but recursive search goes through/excludes the " | ||||
281 | "folders that name is <code>pattern</code></li></ul></p><p>It is allowed to use " | ||||
282 | "quotation marks for names that contain space. Filter " | ||||
283 | "<code>\"Program Files\"</code> searches out those files/folders that name is " | ||||
284 | "<code>Program Files</code>.</p><p>Examples:</p><ul><li><code>*.o</code></" | ||||
285 | "li><li><code>*.h *.c\?\?</code></li><li><code>*.cpp *.h | " | ||||
286 | "*.moc.cpp</code></li><li><code>* | .svn/ .git/</code></li></ul><p><b>Note</b>: the " | ||||
287 | "search term '<code>text</code>' is equivalent to '<code>*text*</code>'.</p>"); | ||||
221 | fileFilter->setWhatsThis(wtFilter); | 288 | fileFilter->setWhatsThis(wtFilter); | ||
222 | filterLabel->setWhatsThis(wtFilter); | 289 | filterLabel->setWhatsThis(wtFilter); | ||
223 | 290 | | |||
224 | rightLocation = new KHistoryComboBox(compareDirs); | 291 | rightLocation = createHistoryComboBox(compareGroupBox, !hasSelectedFiles); | ||
225 | rightLocation->setMaxCount(25); // remember 25 items | 292 | rightLocation->setHistoryItems(group.readEntry("Right Folder History", QStringList())); | ||
226 | rightLocation->setDuplicatesEnabled(false); | 293 | rightLocation->setWhatsThis(i18n("The right base folder used during the synchronization process.")); | ||
227 | rightLocation->setEditable(true); | 294 | rightDirLabel->setBuddy(rightLocation); | ||
228 | rightLocation->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | 295 | KUrlRequester *rightUrlReq = new KUrlRequester(rightLocation, compareGroupBox); | ||
229 | list = group.readEntry("Right Folder History", QStringList()); | | |||
230 | rightLocation->setHistoryItems(list); | | |||
231 | KUrlRequester *rightUrlReq = new KUrlRequester(rightLocation, compareDirs); | | |||
232 | rightUrlReq->setUrl(rightURL); | 296 | rightUrlReq->setUrl(rightURL); | ||
233 | rightUrlReq->setMode(KFile::Directory); | 297 | rightUrlReq->setMode(KFile::Directory); | ||
234 | rightUrlReq->setMinimumWidth(250); | 298 | rightUrlReq->setMinimumWidth(250); | ||
235 | grid->addWidget(rightUrlReq, 1 , 2); | | |||
236 | rightLocation->setWhatsThis(i18n("The right base folder used during the synchronization process.")); | | |||
237 | rightUrlReq->setEnabled(!hasSelectedFiles); | 299 | rightUrlReq->setEnabled(!hasSelectedFiles); | ||
238 | rightLocation->setEnabled(!hasSelectedFiles); | 300 | grid->addWidget(rightUrlReq, 1 , 2); | ||
239 | rightDirLabel->setBuddy(rightLocation); | | |||
240 | 301 | | |||
241 | QWidget *optionWidget = new QWidget(compareDirs); | 302 | QWidget *optionWidget = new QWidget(compareGroupBox); | ||
242 | QHBoxLayout *optionBox = new QHBoxLayout(optionWidget); | 303 | QHBoxLayout *optionBox = new QHBoxLayout(optionWidget); | ||
243 | optionBox->setContentsMargins(0, 0, 0, 0); | 304 | optionBox->setContentsMargins(0, 0, 0, 0); | ||
244 | 305 | | |||
245 | QWidget *optionGridWidget = new QWidget(optionWidget); | 306 | QWidget *optionGridWidget = new QWidget(optionWidget); | ||
246 | QGridLayout *optionGrid = new QGridLayout(optionGridWidget); | 307 | QGridLayout *optionGrid = new QGridLayout(optionGridWidget); | ||
247 | 308 | | |||
248 | optionBox->addWidget(optionGridWidget); | 309 | optionBox->addWidget(optionGridWidget); | ||
249 | 310 | | |||
250 | cbSubdirs = new QCheckBox(i18n("Recurse subfolders"), optionGridWidget); | 311 | cbSubdirs = new QCheckBox(i18n("Recurse subfolders"), optionGridWidget); | ||
251 | cbSubdirs->setChecked(group.readEntry("Recurse Subdirectories", _RecurseSubdirs)); | 312 | cbSubdirs->setChecked(group.readEntry("Recurse Subdirectories", _RecurseSubdirs)); | ||
252 | optionGrid->addWidget(cbSubdirs, 0, 0); | 313 | optionGrid->addWidget(cbSubdirs, 0, 0); | ||
253 | cbSubdirs->setWhatsThis(i18n("Compare not only the base folders but their subfolders as well.")); | 314 | cbSubdirs->setWhatsThis(i18n("Compare not only the base folders but their subfolders as well.")); | ||
254 | cbSymlinks = new QCheckBox(i18n("Follow symlinks"), optionGridWidget); | 315 | cbSymlinks = new QCheckBox(i18n("Follow symlinks"), optionGridWidget); | ||
255 | cbSymlinks->setChecked(group.readEntry("Follow Symlinks", _FollowSymlinks)); | 316 | cbSymlinks->setChecked(group.readEntry("Follow Symlinks", _FollowSymlinks)); | ||
256 | cbSymlinks->setEnabled(cbSubdirs->isChecked()); | 317 | cbSymlinks->setEnabled(cbSubdirs->isChecked()); | ||
257 | optionGrid->addWidget(cbSymlinks, 0, 1); | 318 | optionGrid->addWidget(cbSymlinks, 0, 1); | ||
258 | cbSymlinks->setWhatsThis(i18n("Follow symbolic links during the compare process.")); | 319 | cbSymlinks->setWhatsThis(i18n("Follow symbolic links during the compare process.")); | ||
259 | cbByContent = new QCheckBox(i18n("Compare by content"), optionGridWidget); | 320 | cbByContent = new QCheckBox(i18n("Compare by content"), optionGridWidget); | ||
260 | cbByContent->setChecked(group.readEntry("Compare By Content", _CompareByContent)); | 321 | cbByContent->setChecked(group.readEntry("Compare By Content", _CompareByContent)); | ||
261 | optionGrid->addWidget(cbByContent, 0, 2); | 322 | optionGrid->addWidget(cbByContent, 0, 2); | ||
262 | cbByContent->setWhatsThis(i18n("Compare duplicated files with same size by content.")); | 323 | cbByContent->setWhatsThis(i18n("Compare duplicated files with same size by content.")); | ||
263 | cbIgnoreDate = new QCheckBox(i18n("Ignore Date"), optionGridWidget); | 324 | cbIgnoreDate = new QCheckBox(i18n("Ignore Date"), optionGridWidget); | ||
264 | cbIgnoreDate->setChecked(group.readEntry("Ignore Date", _IgnoreDate)); | 325 | cbIgnoreDate->setChecked(group.readEntry("Ignore Date", _IgnoreDate)); | ||
265 | optionGrid->addWidget(cbIgnoreDate, 1, 0); | 326 | optionGrid->addWidget(cbIgnoreDate, 1, 0); | ||
266 | cbIgnoreDate->setWhatsThis(i18n("<p>Ignore date information during the compare process.</p><p><b>Note</b>: useful if the files are located on network filesystems or in archives.</p>")); | 327 | cbIgnoreDate->setWhatsThis( | ||
328 | i18n("<p>Ignore date information during the compare process.</p><p><b>Note</b>: useful if " | ||||
329 | "the files are located on network filesystems or in archives.</p>")); | ||||
267 | cbAsymmetric = new QCheckBox(i18n("Asymmetric"), optionGridWidget); | 330 | cbAsymmetric = new QCheckBox(i18n("Asymmetric"), optionGridWidget); | ||
268 | cbAsymmetric->setChecked(group.readEntry("Asymmetric", _Asymmetric)); | 331 | cbAsymmetric->setChecked(group.readEntry("Asymmetric", _Asymmetric)); | ||
269 | optionGrid->addWidget(cbAsymmetric, 1, 1); | 332 | optionGrid->addWidget(cbAsymmetric, 1, 1); | ||
270 | cbAsymmetric->setWhatsThis(i18n("<p><b>Asymmetric mode</b></p><p>The left side is the destination, the right is the source folder. Files existing only in the left folder will be deleted, the other differing ones will be copied from right to left.</p><p><b>Note</b>: useful when updating a folder from a file server.</p>")); | 333 | cbAsymmetric->setWhatsThis( | ||
334 | i18n("<p><b>Asymmetric mode</b></p><p>The left side is the destination, the right is the " | ||||
335 | "source folder. Files existing only in the left folder will be deleted, the other " | ||||
336 | "differing ones will be copied from right to left.</p><p><b>Note</b>: useful when " | ||||
337 | "updating a folder from a file server.</p>")); | ||||
271 | cbIgnoreCase = new QCheckBox(i18n("Ignore Case"), optionGridWidget); | 338 | cbIgnoreCase = new QCheckBox(i18n("Ignore Case"), optionGridWidget); | ||
272 | cbIgnoreCase->setChecked(group.readEntry("Ignore Case", _IgnoreCase)); | 339 | cbIgnoreCase->setChecked(group.readEntry("Ignore Case", _IgnoreCase)); | ||
273 | optionGrid->addWidget(cbIgnoreCase, 1, 2); | 340 | optionGrid->addWidget(cbIgnoreCase, 1, 2); | ||
274 | cbIgnoreCase->setWhatsThis(i18n("<p>Case insensitive filename compare.</p><p><b>Note</b>: useful when synchronizing Windows filesystems.</p>")); | 341 | cbIgnoreCase->setWhatsThis(i18n("<p>Case insensitive filename compare.</p><p><b>Note</b>: " | ||
342 | "useful when synchronizing Windows filesystems.</p>")); | ||||
275 | 343 | | |||
276 | /* =========================== Show options groupbox ============================= */ | 344 | /* =========================== Show options groupbox ============================= */ | ||
277 | 345 | | |||
278 | QGroupBox *showOptions = new QGroupBox(optionWidget); | 346 | QGroupBox *showOptions = new QGroupBox(optionWidget); | ||
279 | optionBox->addWidget(showOptions); | 347 | optionBox->addWidget(showOptions); | ||
280 | 348 | | |||
281 | showOptions->setTitle(i18n("S&how options")); | 349 | showOptions->setTitle(i18n("S&how options")); | ||
282 | showOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 350 | showOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
327 | checked = group.readEntry("Singles Button", _BtnSingles); | 395 | checked = group.readEntry("Singles Button", _BtnSingles); | ||
328 | description = i18n("Show files that exist on one side only."); | 396 | description = i18n("Show files that exist on one side only."); | ||
329 | btnSingles = createButton(showOptions, "arrow-down", checked, Qt::CTRL + Qt::Key_N, description, | 397 | btnSingles = createButton(showOptions, "arrow-down", checked, Qt::CTRL + Qt::Key_N, description, | ||
330 | i18n("Singles"), true); | 398 | i18n("Singles"), true); | ||
331 | showOptionsLayout->addWidget(btnSingles, 0, 6); | 399 | showOptionsLayout->addWidget(btnSingles, 0, 6); | ||
332 | 400 | | |||
333 | grid->addWidget(optionWidget, 2, 0, 1, 3); | 401 | grid->addWidget(optionWidget, 2, 0, 1, 3); | ||
334 | 402 | | |||
335 | synchronizerGrid->addWidget(compareDirs, 0, 0); | 403 | synchronizerGrid->addWidget(compareGroupBox, 0, 0); | ||
336 | 404 | | |||
337 | /* ========================= Synchronization list view ========================== */ | 405 | /* ========================= Synchronization list view ========================== */ | ||
338 | syncList = new SynchronizerListView(&synchronizer, synchronizerTab); // create the main container | 406 | syncList = new SynchronizerListView(&synchronizer, synchronizerTab); // create the main container | ||
339 | syncList->setWhatsThis(i18n("The compare results of the synchronizer (Ctrl+M).")); | 407 | syncList->setWhatsThis(i18n("The compare results of the synchronizer (Ctrl+M).")); | ||
340 | syncList->setAutoFillBackground(true); | 408 | syncList->setAutoFillBackground(true); | ||
341 | syncList->installEventFilter(this); | 409 | syncList->installEventFilter(this); | ||
342 | 410 | | |||
343 | KConfigGroup gl(krConfig, "Look&Feel"); | 411 | KConfigGroup gl(krConfig, "Look&Feel"); | ||
▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Line(s) | |||||
575 | 643 | | |||
576 | QString COLOR_NAMES[] = { "Equals", "Differs", "LeftCopy", "RightCopy", "Delete" }; | 644 | QString COLOR_NAMES[] = { "Equals", "Differs", "LeftCopy", "RightCopy", "Delete" }; | ||
577 | QPalette defaultPalette = QGuiApplication::palette(); | 645 | QPalette defaultPalette = QGuiApplication::palette(); | ||
578 | 646 | | |||
579 | DECLARE_SYNCHRONIZER_BACKGROUND_DEFAULTS; | 647 | DECLARE_SYNCHRONIZER_BACKGROUND_DEFAULTS; | ||
580 | DECLARE_SYNCHRONIZER_FOREGROUND_DEFAULTS; | 648 | DECLARE_SYNCHRONIZER_FOREGROUND_DEFAULTS; | ||
581 | 649 | | |||
582 | for (int clr = 0; clr != TT_MAX; clr ++) { | 650 | for (int clr = 0; clr != TT_MAX; clr ++) { | ||
583 | QString colorName = clr > 4 ? "Equals" : COLOR_NAMES[ clr ]; | 651 | const QString colorName = clr > 4 ? "Equals" : COLOR_NAMES[clr]; | ||
584 | QColor backgroundDefault = clr > 4 ? defaultPalette.color(QPalette::Active, QPalette::Base) : SYNCHRONIZER_BACKGROUND_DEFAULTS[ clr ]; | 652 | const QColor backgroundDefault = | ||
585 | QColor foregroundDefault = clr > 4 ? defaultPalette.color(QPalette::Active, QPalette::Text) : SYNCHRONIZER_FOREGROUND_DEFAULTS[ clr ]; | 653 | clr > 4 ? defaultPalette.color(QPalette::Active, QPalette::Base) : | ||
654 | SYNCHRONIZER_BACKGROUND_DEFAULTS[clr]; | ||||
655 | const QColor foregroundDefault = | ||||
656 | clr > 4 ? defaultPalette.color(QPalette::Active, QPalette::Text) : | ||||
657 | SYNCHRONIZER_FOREGROUND_DEFAULTS[clr]; | ||||
586 | 658 | | |||
587 | QString foreEntry = QString("Synchronizer ") + colorName + QString(" Foreground"); | 659 | const QString foreEntry = QString("Synchronizer ") + colorName + QString(" Foreground"); | ||
588 | QString bckgEntry = QString("Synchronizer ") + colorName + QString(" Background"); | 660 | const QString bckgEntry = QString("Synchronizer ") + colorName + QString(" Background"); | ||
589 | 661 | | |||
590 | if (gc.readEntry(foreEntry, QString()) == "KDE default") | 662 | if (gc.readEntry(foreEntry, QString()) == "KDE default") | ||
591 | foreGrounds[ clr ] = QColor(); | 663 | foreGrounds[ clr ] = QColor(); | ||
592 | else if (gc.readEntry(foreEntry, QString()).isEmpty()) // KDE4 workaround, default color doesn't work | 664 | else if (gc.readEntry(foreEntry, QString()).isEmpty()) // KDE4 workaround, default color doesn't work | ||
593 | foreGrounds[ clr ] = foregroundDefault; | 665 | foreGrounds[ clr ] = foregroundDefault; | ||
594 | else | 666 | else | ||
595 | foreGrounds[ clr ] = gc.readEntry(foreEntry, foregroundDefault); | 667 | foreGrounds[ clr ] = gc.readEntry(foreEntry, foregroundDefault); | ||
596 | 668 | | |||
597 | if (gc.readEntry(bckgEntry, QString()) == "KDE default") | 669 | if (gc.readEntry(bckgEntry, QString()) == "KDE default") | ||
598 | backGrounds[ clr ] = QColor(); | 670 | backGrounds[ clr ] = QColor(); | ||
599 | else if (gc.readEntry(foreEntry, QString()).isEmpty()) // KDE4 workaround, default color doesn't work | 671 | else if (gc.readEntry(foreEntry, QString()).isEmpty()) // KDE4 workaround, default color doesn't work | ||
600 | backGrounds[ clr ] = backgroundDefault; | 672 | backGrounds[ clr ] = backgroundDefault; | ||
601 | else | 673 | else | ||
602 | backGrounds[ clr ] = gc.readEntry(bckgEntry, backgroundDefault); | 674 | backGrounds[ clr ] = gc.readEntry(bckgEntry, backgroundDefault); | ||
603 | } | 675 | } | ||
604 | if (backGrounds[ TT_EQUALS ].isValid()) { | 676 | if (backGrounds[ TT_EQUALS ].isValid()) { | ||
605 | QPalette pal = syncList->palette(); | 677 | QPalette pal = syncList->palette(); | ||
606 | pal.setColor(QPalette::Base, backGrounds[ TT_EQUALS ]); | 678 | pal.setColor(QPalette::Base, backGrounds[ TT_EQUALS ]); | ||
607 | syncList->setPalette(pal); | 679 | syncList->setPalette(pal); | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 715 | { | |||
653 | } else { | 725 | } else { | ||
654 | leftDirLabel->setText(i18n("&Left folder:")); | 726 | leftDirLabel->setText(i18n("&Left folder:")); | ||
655 | rightDirLabel->setText(i18n("&Right folder:")); | 727 | rightDirLabel->setText(i18n("&Right folder:")); | ||
656 | } | 728 | } | ||
657 | } | 729 | } | ||
658 | 730 | | |||
659 | void SynchronizerGUI::setCompletion() | 731 | void SynchronizerGUI::setCompletion() | ||
660 | { | 732 | { | ||
661 | generalFilter->dontSearchIn->setCompletionDir(Synchronizer::fsUrl(rightLocation->currentText())); | 733 | generalFilter->dontSearchIn->setCompletionDir(getUrl(rightLocation)); | ||
662 | } | 734 | } | ||
663 | 735 | | |||
664 | void SynchronizerGUI::checkExcludeURLValidity(QString &text, QString &error) | 736 | void SynchronizerGUI::checkExcludeURLValidity(QString &text, QString &error) | ||
665 | { | 737 | { | ||
666 | QUrl url = Synchronizer::fsUrl(text); | 738 | const QUrl url(text); | ||
667 | if (url.isRelative()) | 739 | if (url.isRelative()) | ||
668 | return; | 740 | return; | ||
669 | 741 | | |||
670 | QString leftBase = leftLocation->currentText(); | 742 | const QUrl leftBaseURL = getUrl(leftLocation); | ||
671 | if (!leftBase.endsWith('/')) | | |||
672 | leftBase += '/'; | | |||
673 | QUrl leftBaseURL = Synchronizer::fsUrl(leftBase); | | |||
674 | if (leftBaseURL.isParentOf(url) && !url.isParentOf(leftBaseURL)) { | 743 | if (leftBaseURL.isParentOf(url) && !url.isParentOf(leftBaseURL)) { | ||
675 | text = QDir(leftBaseURL.path()).relativeFilePath(url.path()); | 744 | text = QDir(leftBaseURL.path()).relativeFilePath(url.path()); | ||
676 | return; | 745 | return; | ||
677 | } | 746 | } | ||
678 | 747 | | |||
679 | QString rightBase = rightLocation->currentText(); | 748 | const QUrl rightBaseURL = getUrl(rightLocation); | ||
680 | if (!rightBase.endsWith('/')) | | |||
681 | rightBase += '/'; | | |||
682 | QUrl rightBaseURL = Synchronizer::fsUrl(rightBase); | | |||
683 | if (rightBaseURL.isParentOf(url) && !url.isParentOf(rightBaseURL)) { | 749 | if (rightBaseURL.isParentOf(url) && !url.isParentOf(rightBaseURL)) { | ||
684 | text = QDir(rightBaseURL.path()).relativeFilePath(url.path()); | 750 | text = QDir(rightBaseURL.path()).relativeFilePath(url.path()); | ||
685 | return; | 751 | return; | ||
686 | } | 752 | } | ||
687 | 753 | | |||
688 | error = i18n("URL must be the descendant of either the left or the right base URL."); | 754 | error = i18n("URL must be the descendant of either the left or the right base URL."); | ||
689 | } | 755 | } | ||
690 | 756 | | |||
691 | void SynchronizerGUI::doubleClicked(QTreeWidgetItem *itemIn) | 757 | void SynchronizerGUI::doubleClicked(QTreeWidgetItem *itemIn) | ||
692 | { | 758 | { | ||
693 | if (!itemIn) | 759 | if (!itemIn) | ||
694 | return; | 760 | return; | ||
695 | 761 | | |||
696 | SyncViewItem *syncItem = (SyncViewItem *)itemIn; | 762 | SyncViewItem *syncItem = (SyncViewItem *)itemIn; | ||
697 | SynchronizerFileItem *item = syncItem->synchronizerItemRef(); | 763 | SynchronizerFileItem *item = syncItem->synchronizerItemRef(); | ||
698 | if (item && item->existsInLeft() && item->existsInRight() && !item->isDir()) { | 764 | if (item && item->existsLeft() && item->existsRight() && !item->isDir()) { | ||
699 | QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; | 765 | const QUrl leftURL = Synchronizer::pathAppend(synchronizer.leftBaseDirectory(), | ||
700 | QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; | 766 | item->leftDirectory(), item->leftName()); | ||
701 | QUrl leftURL = Synchronizer::fsUrl(synchronizer.leftBaseDirectory() + leftDirName + item->leftName()); | 767 | const QUrl rightURL = Synchronizer::pathAppend(synchronizer.rightBaseDirectory(), | ||
702 | QUrl rightURL = Synchronizer::fsUrl(synchronizer.rightBaseDirectory() + rightDirName + item->rightName()); | 768 | item->rightDirectory(), item->rightName()); | ||
703 | 769 | | |||
704 | SLOTS->compareContent(leftURL,rightURL); | 770 | SLOTS->compareContent(leftURL,rightURL); | ||
705 | } else if (item && item->isDir()) { | 771 | } else if (item && item->isDir()) { | ||
706 | itemIn->setExpanded(!itemIn->isExpanded()); | 772 | itemIn->setExpanded(!itemIn->isExpanded()); | ||
707 | } | 773 | } | ||
708 | } | 774 | } | ||
709 | 775 | | |||
710 | void SynchronizerGUI::rightMouseClicked(QTreeWidgetItem *itemIn, const QPoint &pos) | 776 | void SynchronizerGUI::rightMouseClicked(QTreeWidgetItem *itemIn, const QPoint &pos) | ||
Show All 19 Lines | 795 | if (!itemIn) | |||
730 | return; | 796 | return; | ||
731 | 797 | | |||
732 | SyncViewItem *syncItem = (SyncViewItem *)itemIn; | 798 | SyncViewItem *syncItem = (SyncViewItem *)itemIn; | ||
733 | if (syncItem == 0) | 799 | if (syncItem == 0) | ||
734 | return; | 800 | return; | ||
735 | 801 | | |||
736 | SynchronizerFileItem *item = syncItem->synchronizerItemRef(); | 802 | SynchronizerFileItem *item = syncItem->synchronizerItemRef(); | ||
737 | 803 | | |||
738 | bool isDuplicate = item->existsInLeft() && item->existsInRight(); | 804 | bool isDuplicate = item->existsLeft() && item->existsRight(); | ||
739 | bool isDir = item->isDir(); | 805 | bool isDir = item->isDir(); | ||
740 | 806 | | |||
741 | // create the menu | 807 | // create the menu | ||
742 | QMenu popup; | 808 | QMenu popup; | ||
743 | QAction *myact; | 809 | QAction *myact; | ||
744 | QHash< QAction *, int > actHash; | 810 | QHash< QAction *, int > actHash; | ||
745 | 811 | | |||
746 | popup.setTitle(i18n("Synchronize Folders")); | 812 | popup.setTitle(i18n("Synchronize Folders")); | ||
Show All 9 Lines | |||||
756 | myact = popup.addAction(i18n("Copy from &left to right")); | 822 | myact = popup.addAction(i18n("Copy from &left to right")); | ||
757 | actHash[ myact ] = COPY_TO_RIGHT_ID; | 823 | actHash[ myact ] = COPY_TO_RIGHT_ID; | ||
758 | myact = popup.addAction(i18n("&Delete (left single)")); | 824 | myact = popup.addAction(i18n("&Delete (left single)")); | ||
759 | actHash[ myact ] = DELETE_ID; | 825 | actHash[ myact ] = DELETE_ID; | ||
760 | 826 | | |||
761 | popup.addSeparator(); | 827 | popup.addSeparator(); | ||
762 | 828 | | |||
763 | myact = popup.addAction(i18n("V&iew left file")); | 829 | myact = popup.addAction(i18n("V&iew left file")); | ||
764 | myact->setEnabled(!isDir && item->existsInLeft()); | 830 | myact->setEnabled(!isDir && item->existsLeft()); | ||
765 | actHash[ myact ] = VIEW_LEFT_FILE_ID; | 831 | actHash[ myact ] = VIEW_LEFT_FILE_ID; | ||
766 | myact = popup.addAction(i18n("Vi&ew right file")); | 832 | myact = popup.addAction(i18n("Vi&ew right file")); | ||
767 | myact->setEnabled(!isDir && item->existsInRight()); | 833 | myact->setEnabled(!isDir && item->existsRight()); | ||
768 | actHash[ myact ] = VIEW_RIGHT_FILE_ID; | 834 | actHash[ myact ] = VIEW_RIGHT_FILE_ID; | ||
769 | myact = popup.addAction(i18n("&Compare Files")); | 835 | myact = popup.addAction(i18n("&Compare Files")); | ||
770 | myact->setEnabled(!isDir && isDuplicate); | 836 | myact->setEnabled(!isDir && isDuplicate); | ||
771 | actHash[ myact ] = COMPARE_FILES_ID; | 837 | actHash[ myact ] = COMPARE_FILES_ID; | ||
772 | 838 | | |||
773 | popup.addSeparator(); | 839 | popup.addSeparator(); | ||
774 | 840 | | |||
775 | myact = popup.addAction(i18n("C&opy selected to clipboard (left)")); | 841 | myact = popup.addAction(i18n("C&opy selected to clipboard (left)")); | ||
776 | actHash[ myact ] = COPY_CLPBD_LEFT_ID; | 842 | actHash[ myact ] = COPY_CLPBD_LEFT_ID; | ||
777 | myact = popup.addAction(i18n("Co&py selected to clipboard (right)")); | 843 | myact = popup.addAction(i18n("Co&py selected to clipboard (right)")); | ||
778 | actHash[ myact ] = COPY_CLPBD_RIGHT_ID; | 844 | actHash[ myact ] = COPY_CLPBD_RIGHT_ID; | ||
779 | 845 | | |||
780 | popup.addSeparator(); | 846 | popup.addSeparator(); | ||
781 | 847 | | |||
782 | myact = popup.addAction(i18n("&Select items")); | 848 | myact = popup.addAction(i18n("&Select items")); | ||
783 | actHash[ myact ] = SELECT_ITEMS_ID; | 849 | actHash[ myact ] = SELECT_ITEMS_ID; | ||
784 | myact = popup.addAction(i18n("Deselec&t items")); | 850 | myact = popup.addAction(i18n("Deselec&t items")); | ||
785 | actHash[ myact ] = DESELECT_ITEMS_ID; | 851 | actHash[ myact ] = DESELECT_ITEMS_ID; | ||
786 | myact = popup.addAction(i18n("I&nvert selection")); | 852 | myact = popup.addAction(i18n("I&nvert selection")); | ||
787 | actHash[ myact ] = INVERT_SELECTION_ID; | 853 | actHash[ myact ] = INVERT_SELECTION_ID; | ||
788 | 854 | | |||
789 | QUrl leftBDir = Synchronizer::fsUrl(synchronizer.leftBaseDirectory()); | 855 | const QUrl leftBDir = synchronizer.leftBaseDirectory(); | ||
790 | QUrl rightBDir = Synchronizer::fsUrl(synchronizer.rightBaseDirectory()); | 856 | const QUrl rightBDir = synchronizer.rightBaseDirectory(); | ||
791 | 857 | | |||
792 | if (KrServices::cmdExist("kget") && | 858 | if (KrServices::cmdExist("kget") && | ||
793 | ((!leftBDir.isLocalFile() && rightBDir.isLocalFile() && btnLeftToRight->isChecked()) || | 859 | ((!leftBDir.isLocalFile() && rightBDir.isLocalFile() && btnLeftToRight->isChecked()) || | ||
794 | (leftBDir.isLocalFile() && !rightBDir.isLocalFile() && btnRightToLeft->isChecked()))) { | 860 | (leftBDir.isLocalFile() && !rightBDir.isLocalFile() && btnRightToLeft->isChecked()))) { | ||
795 | popup.addSeparator(); | 861 | popup.addSeparator(); | ||
796 | myact = popup.addAction(i18n("Synchronize with &KGet")); | 862 | myact = popup.addAction(i18n("Synchronize with &KGet")); | ||
797 | actHash[ myact ] = SYNCH_WITH_KGET_ID; | 863 | actHash[ myact ] = SYNCH_WITH_KGET_ID; | ||
798 | } | 864 | } | ||
799 | 865 | | |||
800 | QAction * res = popup.exec(pos); | 866 | QAction * res = popup.exec(pos); | ||
801 | 867 | | |||
802 | int result = -1; | 868 | int result = -1; | ||
803 | if (actHash.contains(res)) | 869 | if (actHash.contains(res)) | ||
804 | result = actHash[ res ]; | 870 | result = actHash[ res ]; | ||
805 | 871 | | |||
806 | if (result != -1) | 872 | if (result != -1) | ||
807 | executeOperation(item, result); | 873 | executeOperation(item, result); | ||
808 | } | 874 | } | ||
809 | 875 | | |||
810 | void SynchronizerGUI::executeOperation(SynchronizerFileItem *item, int op) | 876 | void SynchronizerGUI::executeOperation(SynchronizerFileItem *item, int op) | ||
811 | { | 877 | { | ||
812 | // check out the user's option | 878 | // check out the user's option | ||
813 | QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; | | |||
814 | QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; | | |||
815 | 879 | | |||
816 | QUrl leftURL = Synchronizer::fsUrl(synchronizer.leftBaseDirectory() + leftDirName + item->leftName()); | 880 | const QUrl leftURL = Synchronizer::pathAppend(synchronizer.leftBaseDirectory(), | ||
817 | QUrl rightURL = Synchronizer::fsUrl(synchronizer.rightBaseDirectory() + rightDirName + item->rightName()); | 881 | item->leftDirectory(), item->leftName()); | ||
882 | const QUrl rightURL = Synchronizer::pathAppend(synchronizer.rightBaseDirectory(), | ||||
883 | item->rightDirectory(), item->rightName()); | ||||
818 | 884 | | |||
819 | switch (op) { | 885 | switch (op) { | ||
820 | case EXCLUDE_ID: | 886 | case EXCLUDE_ID: | ||
821 | case RESTORE_ID: | 887 | case RESTORE_ID: | ||
822 | case COPY_TO_LEFT_ID: | 888 | case COPY_TO_LEFT_ID: | ||
823 | case COPY_TO_RIGHT_ID: | 889 | case COPY_TO_RIGHT_ID: | ||
824 | case REVERSE_DIR_ID: | 890 | case REVERSE_DIR_ID: | ||
825 | case DELETE_ID: { | 891 | case DELETE_ID: { | ||
826 | unsigned ndx = 0; | 892 | unsigned ndx = 0; | ||
827 | SynchronizerFileItem *currentItem; | 893 | SynchronizerFileItem *currentItem; | ||
828 | 894 | | |||
829 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | 895 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | ||
830 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); | 896 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->viewItem(); | ||
831 | 897 | | |||
832 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | 898 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | ||
833 | continue; | 899 | continue; | ||
834 | 900 | | |||
835 | switch (op) { | 901 | switch (op) { | ||
836 | case EXCLUDE_ID: | 902 | case EXCLUDE_ID: | ||
837 | synchronizer.exclude(viewItem->synchronizerItemRef()); | 903 | synchronizer.exclude(viewItem->synchronizerItemRef()); | ||
838 | break; | 904 | break; | ||
Show All 33 Lines | 937 | KRQuery query = KRSpWidgets::getMask((op == SELECT_ITEMS_ID ? i18n("Select items") : | |||
872 | i18n("Deselect items")), true, this); | 938 | i18n("Deselect items")), true, this); | ||
873 | if (query.isNull()) | 939 | if (query.isNull()) | ||
874 | break; | 940 | break; | ||
875 | 941 | | |||
876 | unsigned ndx = 0; | 942 | unsigned ndx = 0; | ||
877 | SynchronizerFileItem *currentItem; | 943 | SynchronizerFileItem *currentItem; | ||
878 | 944 | | |||
879 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | 945 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | ||
880 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); | 946 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->viewItem(); | ||
881 | 947 | | |||
882 | if (!viewItem || viewItem->isHidden()) | 948 | if (!viewItem || viewItem->isHidden()) | ||
883 | continue; | 949 | continue; | ||
884 | 950 | | |||
885 | if (query.match(currentItem->leftName()) || | 951 | if (query.match(currentItem->leftName()) || | ||
886 | query.match(currentItem->rightName())) | 952 | query.match(currentItem->rightName())) | ||
887 | viewItem->setSelected(op == SELECT_ITEMS_ID); | 953 | viewItem->setSelected(op == SELECT_ITEMS_ID); | ||
888 | } | 954 | } | ||
889 | } | 955 | } | ||
890 | break; | 956 | break; | ||
891 | case INVERT_SELECTION_ID: { | 957 | case INVERT_SELECTION_ID: { | ||
892 | unsigned ndx = 0; | 958 | unsigned ndx = 0; | ||
893 | SynchronizerFileItem *currentItem; | 959 | SynchronizerFileItem *currentItem; | ||
894 | 960 | | |||
895 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | 961 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | ||
896 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->userData(); | 962 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->viewItem(); | ||
897 | 963 | | |||
898 | if (!viewItem || viewItem->isHidden()) | 964 | if (!viewItem || viewItem->isHidden()) | ||
899 | continue; | 965 | continue; | ||
900 | 966 | | |||
901 | viewItem->setSelected(!viewItem->isSelected()); | 967 | viewItem->setSelected(!viewItem->isSelected()); | ||
902 | } | 968 | } | ||
903 | } | 969 | } | ||
904 | break; | 970 | break; | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 1044 | if (wasSync) { | |||
979 | LEFT_PANEL->func->refresh(); | 1045 | LEFT_PANEL->func->refresh(); | ||
980 | RIGHT_PANEL->func->refresh(); | 1046 | RIGHT_PANEL->func->refresh(); | ||
981 | ACTIVE_PANEL->gui->slotFocusOnMe(); | 1047 | ACTIVE_PANEL->gui->slotFocusOnMe(); | ||
982 | } | 1048 | } | ||
983 | } | 1049 | } | ||
984 | 1050 | | |||
985 | void SynchronizerGUI::compare() | 1051 | void SynchronizerGUI::compare() | ||
986 | { | 1052 | { | ||
987 | KRQuery query; | 1053 | KRQuery query = filterTabs->query(); | ||
988 | 1054 | if (query.isNull()) | |||
989 | if (!filterTabs->fillQuery(&query)) | | |||
990 | return; | 1055 | return; | ||
991 | 1056 | | |||
992 | // perform some previous tests | 1057 | // perform some previous tests | ||
993 | QString leftLocationTrimmed = leftLocation->currentText().trimmed(); | 1058 | QString leftLocationTrimmed = leftLocation->currentText().trimmed(); | ||
994 | QString rightLocationTrimmed = rightLocation->currentText().trimmed(); | 1059 | QString rightLocationTrimmed = rightLocation->currentText().trimmed(); | ||
995 | if (leftLocationTrimmed.isEmpty()) { | 1060 | if (leftLocationTrimmed.isEmpty()) { | ||
996 | KMessageBox::error(this, i18n("The target folder must not be empty.")); | 1061 | KMessageBox::error(this, i18n("The target folder must not be empty.")); | ||
997 | leftLocation->setFocus(); | 1062 | leftLocation->setFocus(); | ||
Show All 31 Lines | |||||
1029 | btnStopComparing->show(); | 1094 | btnStopComparing->show(); | ||
1030 | btnFeedToListBox->setEnabled(false); | 1095 | btnFeedToListBox->setEnabled(false); | ||
1031 | btnFeedToListBox->hide(); | 1096 | btnFeedToListBox->hide(); | ||
1032 | btnSynchronize->setEnabled(false); | 1097 | btnSynchronize->setEnabled(false); | ||
1033 | btnCompareDirs->hide(); | 1098 | btnCompareDirs->hide(); | ||
1034 | btnScrollResults->show(); | 1099 | btnScrollResults->show(); | ||
1035 | disableMarkButtons(); | 1100 | disableMarkButtons(); | ||
1036 | 1101 | | |||
1037 | int fileCount = synchronizer.compare(leftLocation->currentText(), rightLocation->currentText(), | 1102 | int fileCount = synchronizer.compare(getUrl(leftLocation), getUrl(rightLocation), | ||
1038 | &query, cbSubdirs->isChecked(), cbSymlinks->isChecked(), | 1103 | &query, cbSubdirs->isChecked(), cbSymlinks->isChecked(), | ||
1039 | cbIgnoreDate->isChecked(), cbAsymmetric->isChecked(), cbByContent->isChecked(), | 1104 | cbIgnoreDate->isChecked(), cbAsymmetric->isChecked(), cbByContent->isChecked(), | ||
1040 | cbIgnoreCase->isChecked(), btnScrollResults->isChecked(), selectedFiles, | 1105 | cbIgnoreCase->isChecked(), btnScrollResults->isChecked(), selectedFiles, | ||
1041 | convertToSeconds(equalitySpinBox->value(), equalityUnitCombo->currentIndex()), | 1106 | convertToSeconds(equalitySpinBox->value(), equalityUnitCombo->currentIndex()), | ||
1042 | convertToSeconds(timeShiftSpinBox->value(), timeShiftUnitCombo->currentIndex()), | 1107 | convertToSeconds(timeShiftSpinBox->value(), timeShiftUnitCombo->currentIndex()), | ||
1043 | parallelThreadsSpinBox->value(), ignoreHiddenFilesCB->isChecked()); | 1108 | parallelThreadsSpinBox->value(), ignoreHiddenFilesCB->isChecked()); | ||
1044 | enableMarkButtons(); | 1109 | enableMarkButtons(); | ||
1045 | btnStopComparing->setEnabled(isComparing = false); | 1110 | btnStopComparing->setEnabled(isComparing = false); | ||
Show All 35 Lines | |||||
1081 | void SynchronizerGUI::addFile(SynchronizerFileItem *item) | 1146 | void SynchronizerGUI::addFile(SynchronizerFileItem *item) | ||
1082 | { | 1147 | { | ||
1083 | QString leftName = "", rightName = "", leftDate = "", rightDate = "", leftSize = "", rightSize = ""; | 1148 | QString leftName = "", rightName = "", leftDate = "", rightDate = "", leftSize = "", rightSize = ""; | ||
1084 | bool isDir = item->isDir(); | 1149 | bool isDir = item->isDir(); | ||
1085 | 1150 | | |||
1086 | QColor textColor = foreGrounds[ item->task()]; | 1151 | QColor textColor = foreGrounds[ item->task()]; | ||
1087 | QColor baseColor = backGrounds[ item->task()]; | 1152 | QColor baseColor = backGrounds[ item->task()]; | ||
1088 | 1153 | | |||
1089 | if (item->existsInLeft()) { | 1154 | if (item->existsLeft()) { | ||
1090 | leftName = item->leftName(); | 1155 | leftName = item->leftName(); | ||
1091 | leftSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->leftSize()); | 1156 | leftSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->leftSize()); | ||
1092 | leftDate = SynchronizerGUI::convertTime(item->leftDate()); | 1157 | leftDate = SynchronizerGUI::convertTime(item->leftDate()); | ||
1093 | } | 1158 | } | ||
1094 | 1159 | | |||
1095 | if (item->existsInRight()) { | 1160 | if (item->existsRight()) { | ||
1096 | rightName = item->rightName(); | 1161 | rightName = item->rightName(); | ||
1097 | rightSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->rightSize()); | 1162 | rightSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->rightSize()); | ||
1098 | rightDate = SynchronizerGUI::convertTime(item->rightDate()); | 1163 | rightDate = SynchronizerGUI::convertTime(item->rightDate()); | ||
1099 | } | 1164 | } | ||
1100 | 1165 | | |||
1101 | SyncViewItem *listItem = 0; | 1166 | SyncViewItem *listItem = 0; | ||
1102 | SyncViewItem *dirItem; | 1167 | SyncViewItem *dirItem; | ||
1103 | 1168 | | |||
1104 | if (item->parent() == 0) { | 1169 | if (item->parent() == 0) { | ||
1105 | listItem = new SyncViewItem(item, textColor, baseColor, syncList, lastItem, leftName, leftSize, | 1170 | listItem = new SyncViewItem(item, textColor, baseColor, syncList, lastItem, leftName, leftSize, | ||
1106 | leftDate, Synchronizer::getTaskTypeName(item->task()), rightDate, | 1171 | leftDate, Synchronizer::getTaskTypeName(item->task()), rightDate, | ||
1107 | rightSize, rightName); | 1172 | rightSize, rightName); | ||
1108 | lastItem = listItem; | 1173 | lastItem = listItem; | ||
1109 | } else { | 1174 | } else { | ||
1110 | dirItem = (SyncViewItem *)item->parent()->userData(); | 1175 | dirItem = (SyncViewItem *)item->parent()->viewItem(); | ||
1111 | if (dirItem) { | 1176 | if (dirItem) { | ||
1112 | dirItem->setExpanded(true); | 1177 | dirItem->setExpanded(true); | ||
1113 | listItem = new SyncViewItem(item, textColor, baseColor, dirItem, dirItem->lastItem(), leftName, | 1178 | listItem = new SyncViewItem(item, textColor, baseColor, dirItem, dirItem->lastItem(), leftName, | ||
1114 | leftSize, leftDate, Synchronizer::getTaskTypeName(item->task()), | 1179 | leftSize, leftDate, Synchronizer::getTaskTypeName(item->task()), | ||
1115 | rightDate, rightSize, rightName); | 1180 | rightDate, rightSize, rightName); | ||
1116 | 1181 | | |||
1117 | dirItem->setLastItem(listItem); | 1182 | dirItem->setLastItem(listItem); | ||
1118 | } | 1183 | } | ||
1119 | } | 1184 | } | ||
1120 | 1185 | | |||
1121 | if (listItem) { | 1186 | if (listItem) { | ||
1122 | listItem->setIcon(0, Icon(isDir ? "folder" : "document-new")); | 1187 | listItem->setIcon(0, Icon(isDir ? "folder" : "document-new")); | ||
1123 | if (!item->isMarked()) | 1188 | if (!item->isMarked()) | ||
1124 | listItem->setHidden(true); | 1189 | listItem->setHidden(true); | ||
1125 | else | 1190 | else | ||
1126 | syncList->scrollTo(syncList->indexOf(listItem)); | 1191 | syncList->scrollTo(syncList->indexOf(listItem)); | ||
1127 | } | 1192 | } | ||
1128 | } | 1193 | } | ||
1129 | 1194 | | |||
1130 | void SynchronizerGUI::markChanged(SynchronizerFileItem *item, bool ensureVisible) | 1195 | void SynchronizerGUI::markChanged(SynchronizerFileItem *item, bool ensureVisible) | ||
1131 | { | 1196 | { | ||
1132 | SyncViewItem *listItem = (SyncViewItem *)item->userData(); | 1197 | SyncViewItem *listItem = (SyncViewItem *)item->viewItem(); | ||
1133 | if (listItem) { | 1198 | if (listItem) { | ||
1134 | if (!item->isMarked()) { | 1199 | if (!item->isMarked()) { | ||
1135 | listItem->setHidden(true); | 1200 | listItem->setHidden(true); | ||
1136 | } else { | 1201 | } else { | ||
1137 | QString leftName = "", rightName = "", leftDate = "", rightDate = "", leftSize = "", rightSize = ""; | 1202 | QString leftName = "", rightName = "", leftDate = "", rightDate = "", leftSize = "", rightSize = ""; | ||
1138 | bool isDir = item->isDir(); | 1203 | bool isDir = item->isDir(); | ||
1139 | 1204 | | |||
1140 | if (item->existsInLeft()) { | 1205 | if (item->existsLeft()) { | ||
1141 | leftName = item->leftName(); | 1206 | leftName = item->leftName(); | ||
1142 | leftSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->leftSize()); | 1207 | leftSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->leftSize()); | ||
1143 | leftDate = SynchronizerGUI::convertTime(item->leftDate()); | 1208 | leftDate = SynchronizerGUI::convertTime(item->leftDate()); | ||
1144 | } | 1209 | } | ||
1145 | 1210 | | |||
1146 | if (item->existsInRight()) { | 1211 | if (item->existsRight()) { | ||
1147 | rightName = item->rightName(); | 1212 | rightName = item->rightName(); | ||
1148 | rightSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->rightSize()); | 1213 | rightSize = isDir ? dirLabel() + ' ' : KRpermHandler::parseSize(item->rightSize()); | ||
1149 | rightDate = SynchronizerGUI::convertTime(item->rightDate()); | 1214 | rightDate = SynchronizerGUI::convertTime(item->rightDate()); | ||
1150 | } | 1215 | } | ||
1151 | 1216 | | |||
1152 | listItem->setHidden(false); | 1217 | listItem->setHidden(false); | ||
1153 | listItem->setText(0, leftName); | 1218 | listItem->setText(0, leftName); | ||
1154 | listItem->setText(1, leftSize); | 1219 | listItem->setText(1, leftSize); | ||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 1358 | { | |||
1302 | case Qt::Key_F3 : | 1367 | case Qt::Key_F3 : | ||
1303 | case Qt::Key_F4 : { | 1368 | case Qt::Key_F4 : { | ||
1304 | e->accept(); | 1369 | e->accept(); | ||
1305 | syncList->setFocus(); | 1370 | syncList->setFocus(); | ||
1306 | QTreeWidgetItem *listItem = syncList->currentItem(); | 1371 | QTreeWidgetItem *listItem = syncList->currentItem(); | ||
1307 | if (listItem == 0) | 1372 | if (listItem == 0) | ||
1308 | break; | 1373 | break; | ||
1309 | 1374 | | |||
1310 | bool isedit = e->key() == Qt::Key_F4; | 1375 | const bool isedit = e->key() == Qt::Key_F4; | ||
1311 | 1376 | | |||
1312 | SynchronizerFileItem *item = ((SyncViewItem *)listItem)->synchronizerItemRef(); | 1377 | SynchronizerFileItem *item = ((SyncViewItem *)listItem)->synchronizerItemRef(); | ||
1313 | QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; | | |||
1314 | QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; | | |||
1315 | | ||||
1316 | if (item->isDir()) | 1378 | if (item->isDir()) | ||
1317 | return; | 1379 | return; | ||
1318 | 1380 | | |||
1319 | if (e->modifiers() == Qt::ShiftModifier && item->existsInRight()) { | 1381 | if (e->modifiers() == Qt::ShiftModifier && item->existsRight()) { | ||
1320 | QUrl rightURL = Synchronizer::fsUrl(synchronizer.rightBaseDirectory() + rightDirName + item->rightName()); | 1382 | const QUrl rightURL = Synchronizer::pathAppend( | ||
1383 | synchronizer.rightBaseDirectory(), item->rightDirectory(), item->rightName()); | ||||
1384 | | ||||
1321 | if (isedit) | 1385 | if (isedit) | ||
1322 | KrViewer::edit(rightURL, this); // view the file | 1386 | KrViewer::edit(rightURL, this); // view the file | ||
1323 | else | 1387 | else | ||
1324 | KrViewer::view(rightURL, this); // view the file | 1388 | KrViewer::view(rightURL, this); // view the file | ||
1325 | return; | 1389 | return; | ||
1326 | } else if (e->modifiers() == 0 && item->existsInLeft()) { | 1390 | } else if (e->modifiers() == 0 && item->existsLeft()) { | ||
1327 | QUrl leftURL = Synchronizer::fsUrl(synchronizer.leftBaseDirectory() + leftDirName + item->leftName()); | 1391 | const QUrl leftURL = Synchronizer::pathAppend( | ||
1392 | synchronizer.leftBaseDirectory(), item->leftDirectory(), item->leftName()); | ||||
1393 | | ||||
1328 | if (isedit) | 1394 | if (isedit) | ||
1329 | KrViewer::edit(leftURL, this); // view the file | 1395 | KrViewer::edit(leftURL, this); // view the file | ||
1330 | else | 1396 | else | ||
1331 | KrViewer::view(leftURL, this); // view the file | 1397 | KrViewer::view(leftURL, this); // view the file | ||
1332 | return; | 1398 | return; | ||
1333 | } | 1399 | } | ||
1334 | } | 1400 | } | ||
1335 | break; | 1401 | break; | ||
1336 | case Qt::Key_U : | 1402 | case Qt::Key_U : | ||
1337 | if (e->modifiers() != Qt::ControlModifier) | 1403 | if (e->modifiers() != Qt::ControlModifier) | ||
1338 | break; | 1404 | break; | ||
1339 | e->accept(); | 1405 | e->accept(); | ||
1340 | swapSides(); | 1406 | swapSides(); | ||
1341 | return; | 1407 | return; | ||
1342 | case Qt::Key_Escape: | 1408 | case Qt::Key_Escape: | ||
1343 | if (!btnStopComparing->isHidden() && btnStopComparing->isEnabled()) { // is it comparing? | 1409 | if (!btnStopComparing->isHidden() && btnStopComparing->isEnabled()) { // is it comparing? | ||
1344 | e->accept(); | 1410 | e->accept(); | ||
1345 | btnStopComparing->animateClick(); // just click the stop button | 1411 | btnStopComparing->animateClick(); // just click the stop button | ||
1346 | } else { | 1412 | } else { | ||
1347 | e->accept(); | 1413 | e->accept(); | ||
1348 | if (syncList->topLevelItemCount() != 0) { | 1414 | if (syncList->topLevelItemCount() != 0) { | ||
1349 | int result = KMessageBox::warningYesNo(this, i18n("The synchronizer window contains data from a previous compare. If you exit, this data will be lost. Do you really want to exit?"), | 1415 | int result = KMessageBox::warningYesNo( | ||
1350 | i18n("Krusader::Synchronize Folders"), | 1416 | this, i18n("The synchronizer window contains data from a previous compare. If " | ||
1351 | KStandardGuiItem::yes(), KStandardGuiItem::no(), "syncGUIexit"); | 1417 | "you exit, this data will be lost. Do you really want to exit?"), | ||
1418 | i18n("Krusader::Synchronize Folders"), KStandardGuiItem::yes(), | ||||
1419 | KStandardGuiItem::no(), "syncGUIexit"); | ||||
1352 | if (result != KMessageBox::Yes) | 1420 | if (result != KMessageBox::Yes) | ||
1353 | return; | 1421 | return; | ||
1354 | } | 1422 | } | ||
1355 | QDialog::reject(); | 1423 | QDialog::reject(); | ||
1356 | } | 1424 | } | ||
1357 | return; | 1425 | return; | ||
1358 | } | 1426 | } | ||
1359 | 1427 | | |||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Line(s) | |||||
1584 | void SynchronizerGUI::copyToClipboard(bool isLeft) | 1652 | void SynchronizerGUI::copyToClipboard(bool isLeft) | ||
1585 | { | 1653 | { | ||
1586 | QList<QUrl> urls; | 1654 | QList<QUrl> urls; | ||
1587 | 1655 | | |||
1588 | unsigned ndx = 0; | 1656 | unsigned ndx = 0; | ||
1589 | SynchronizerFileItem *currentItem; | 1657 | SynchronizerFileItem *currentItem; | ||
1590 | 1658 | | |||
1591 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | 1659 | while ((currentItem = synchronizer.getItemAt(ndx++)) != 0) { | ||
1592 | SynchronizerGUI::SyncViewItem *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); | 1660 | SyncViewItem *viewItem = (SyncViewItem *)currentItem->viewItem(); | ||
1593 | 1661 | | |||
1594 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | 1662 | if (!viewItem || !viewItem->isSelected() || viewItem->isHidden()) | ||
1595 | continue; | 1663 | continue; | ||
1596 | 1664 | | |||
1597 | SynchronizerFileItem *item = viewItem->synchronizerItemRef(); | 1665 | SynchronizerFileItem *item = viewItem->synchronizerItemRef(); | ||
1598 | if (item) { | 1666 | if (item) { | ||
1599 | if (isLeft && item->existsInLeft()) { | 1667 | if (isLeft && item->existsLeft()) { | ||
1600 | QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + '/'; | 1668 | const QUrl leftURL = Synchronizer::pathAppend( | ||
1601 | QUrl leftURL = Synchronizer::fsUrl(synchronizer.leftBaseDirectory() + leftDirName + item->leftName()); | 1669 | synchronizer.leftBaseDirectory(), item->leftDirectory(), item->leftName()); | ||
1602 | urls.push_back(leftURL); | 1670 | urls.push_back(leftURL); | ||
1603 | } else if (!isLeft && item->existsInRight()) { | 1671 | } else if (!isLeft && item->existsRight()) { | ||
1604 | QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + '/'; | 1672 | const QUrl rightURL = Synchronizer::pathAppend( | ||
1605 | QUrl rightURL = Synchronizer::fsUrl(synchronizer.rightBaseDirectory() + rightDirName + item->rightName()); | 1673 | synchronizer.rightBaseDirectory(), item->rightDirectory(), item->rightName()); | ||
1606 | urls.push_back(rightURL); | 1674 | urls.push_back(rightURL); | ||
1607 | } | 1675 | } | ||
1608 | } | 1676 | } | ||
1609 | } | 1677 | } | ||
1610 | 1678 | | |||
1611 | if (urls.count() == 0) | 1679 | if (urls.count() == 0) | ||
1612 | return; | 1680 | return; | ||
1613 | 1681 | | |||
1614 | QMimeData *mimeData = new QMimeData; | 1682 | QMimeData *mimeData = new QMimeData; | ||
1615 | mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); | 1683 | mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); | ||
1616 | mimeData->setUrls(urls); | 1684 | mimeData->setUrls(urls); | ||
1617 | 1685 | | |||
1618 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); | 1686 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); | ||
1619 | } | 1687 | } | ||
1620 | 1688 | | |||
1621 | QString SynchronizerGUI::dirLabel() | 1689 | QString SynchronizerGUI::dirLabel() | ||
1622 | { | 1690 | { | ||
1623 | //HACK add <> brackets AFTER translating - otherwise KUIT thinks it's a tag | 1691 | //HACK add <> brackets AFTER translating - otherwise KUIT thinks it's a tag | ||
1624 | static QString label = QString("<") + | 1692 | static QString label = QString("<") + | ||
1625 | i18nc("Show the string 'DIR' instead of file size in detailed view (for folders)", "DIR") + '>'; | 1693 | i18nc("Show the string 'DIR' instead of file size in detailed view (for folders)", "DIR") + '>'; | ||
1626 | return label; | 1694 | return label; | ||
1627 | } | 1695 | } | ||
1628 | 1696 | | |||
1697 | KHistoryComboBox *SynchronizerGUI::createHistoryComboBox(QWidget *parent, bool enabled) | ||||
1698 | { | ||||
1699 | KHistoryComboBox *location = new KHistoryComboBox(false, parent); | ||||
1700 | location->setMaxCount(25); // remember 25 items | ||||
1701 | location->setDuplicatesEnabled(false); | ||||
1702 | location->setEditable(true); | ||||
1703 | location->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | ||||
1704 | location->setEnabled(enabled); | ||||
1705 | return location; | ||||
1706 | } | ||||
1707 | | ||||
1708 | QUrl SynchronizerGUI::getUrl(KHistoryComboBox *location) | ||||
1709 | { | ||||
1710 | return QUrl::fromUserInput(location->currentText()); | ||||
1711 | } |