Mercurial > hg > easyhg-kdiff3
comparison kdiff3/src/kreplacements/kreplacements.cpp @ 66:efe33e938730
0.9.86
author | joachim99 |
---|---|
date | Thu, 16 Sep 2004 02:40:08 +0000 |
parents | 8af4bb9d9a5a |
children | d7cafcda8c99 |
comparison
equal
deleted
inserted
replaced
65:8ea11c8efeb5 | 66:efe33e938730 |
---|---|
15 * * | 15 * * |
16 ***************************************************************************/ | 16 ***************************************************************************/ |
17 | 17 |
18 | 18 |
19 #include "kreplacements.h" | 19 #include "kreplacements.h" |
20 #include "common.h" | |
20 | 21 |
21 #include <assert.h> | 22 #include <assert.h> |
22 | 23 |
23 #include <qnamespace.h> | 24 #include <qnamespace.h> |
24 #include <qmessagebox.h> | 25 #include <qmessagebox.h> |
29 #include <qfontdialog.h> | 30 #include <qfontdialog.h> |
30 #include <qlabel.h> | 31 #include <qlabel.h> |
31 #include <qtextbrowser.h> | 32 #include <qtextbrowser.h> |
32 #include <qtextstream.h> | 33 #include <qtextstream.h> |
33 #include <qlayout.h> | 34 #include <qlayout.h> |
35 #include <qdockarea.h> | |
34 | 36 |
35 #include <vector> | 37 #include <vector> |
36 #include <iostream> | 38 #include <iostream> |
37 #include <algorithm> | 39 #include <algorithm> |
40 | |
38 | 41 |
39 static QString s_copyright; | 42 static QString s_copyright; |
40 static QString s_email; | 43 static QString s_email; |
41 static QString s_description; | 44 static QString s_description; |
42 static QString s_appName; | 45 static QString s_appName; |
43 static QString s_version; | 46 static QString s_version; |
44 static QString s_homepage; | 47 static QString s_homepage; |
48 static KAboutData* s_pAboutData; | |
49 | |
45 | 50 |
46 #ifdef _WIN32 | 51 #ifdef _WIN32 |
47 #include <process.h> | 52 #include <process.h> |
48 #include <windows.h> | 53 #include <windows.h> |
49 #endif | 54 #endif |
273 } | 278 } |
274 | 279 |
275 | 280 |
276 KToolBar::BarPosition KToolBar::barPos() | 281 KToolBar::BarPosition KToolBar::barPos() |
277 { | 282 { |
283 if ( m_pMainWindow->leftDock()->hasDockWindow(this) ) return Left; | |
284 if ( m_pMainWindow->rightDock()->hasDockWindow(this) ) return Right; | |
285 if ( m_pMainWindow->topDock()->hasDockWindow(this) ) return Top; | |
286 if ( m_pMainWindow->bottomDock()->hasDockWindow(this) ) return Bottom; | |
278 return Top; | 287 return Top; |
279 } | 288 } |
280 | 289 |
281 void KToolBar::setBarPos(BarPosition) | 290 void KToolBar::setBarPos(BarPosition bp) |
282 { | 291 { |
292 if ( bp == Left ) m_pMainWindow->moveDockWindow( this, DockLeft ); | |
293 else if ( bp == Right ) m_pMainWindow->moveDockWindow( this, DockRight ); | |
294 else if ( bp == Bottom ) m_pMainWindow->moveDockWindow( this, DockBottom ); | |
295 else if ( bp == Top ) m_pMainWindow->moveDockWindow( this, DockTop ); | |
283 } | 296 } |
284 | 297 |
285 KToolBar::KToolBar( QMainWindow* parent ) | 298 KToolBar::KToolBar( QMainWindow* parent ) |
286 : QToolBar( parent ) | 299 : QToolBar( parent ) |
287 { | 300 { |
301 m_pMainWindow = parent; | |
288 } | 302 } |
289 | 303 |
290 | 304 |
291 KMainWindow::KMainWindow( QWidget* parent, const QString& name ) | 305 KMainWindow::KMainWindow( QWidget* parent, const QString& name ) |
292 : QMainWindow( parent, name ), m_actionCollection(this) | 306 : QMainWindow( parent, name ), m_actionCollection(this) |
299 menuBar()->insertItem(i18n("&Directory"), directoryMenu); | 313 menuBar()->insertItem(i18n("&Directory"), directoryMenu); |
300 dirCurrentItemMenu = 0; | 314 dirCurrentItemMenu = 0; |
301 dirCurrentSyncItemMenu = 0; | 315 dirCurrentSyncItemMenu = 0; |
302 movementMenu = new QPopupMenu(); | 316 movementMenu = new QPopupMenu(); |
303 menuBar()->insertItem(i18n("&Movement"), movementMenu); | 317 menuBar()->insertItem(i18n("&Movement"), movementMenu); |
318 diffMenu = new QPopupMenu(); | |
319 menuBar()->insertItem(i18n("D&iffview"), diffMenu); | |
304 mergeMenu = new QPopupMenu(); | 320 mergeMenu = new QPopupMenu(); |
305 menuBar()->insertItem(i18n("&Merge"), mergeMenu); | 321 menuBar()->insertItem(i18n("&Merge"), mergeMenu); |
306 windowsMenu = new QPopupMenu(); | 322 windowsMenu = new QPopupMenu(); |
307 menuBar()->insertItem(i18n("&Window"), windowsMenu); | 323 menuBar()->insertItem(i18n("&Window"), windowsMenu); |
308 settingsMenu = new QPopupMenu(); | 324 settingsMenu = new QPopupMenu(); |
356 } | 372 } |
357 } | 373 } |
358 | 374 |
359 void KMainWindow::slotAbout() | 375 void KMainWindow::slotAbout() |
360 { | 376 { |
377 QTabDialog d; | |
378 d.setCaption("About " + s_appName); | |
379 QTextBrowser* tb1 = new QTextBrowser(&d); | |
380 tb1->setWordWrap( QTextEdit::NoWrap ); | |
381 tb1->setText( | |
382 s_appName + " Version " + s_version + | |
383 "\n\n" + s_description + | |
384 "\n\n" + s_copyright + | |
385 "\n\nHomepage: " + s_homepage + | |
386 "\n\nLicence: GNU GPL Version 2" | |
387 ); | |
388 d.addTab(tb1,i18n("&About")); | |
389 | |
390 std::list<KAboutData::AboutDataEntry>::iterator i; | |
391 | |
392 QString s2; | |
393 for( i=s_pAboutData->m_authorList.begin(); i!=s_pAboutData->m_authorList.end(); ++i ) | |
394 { | |
395 if ( !i->m_name.isEmpty() ) s2 += i->m_name + "\n"; | |
396 if ( !i->m_task.isEmpty() ) s2 += " " + i->m_task + "\n"; | |
397 if ( !i->m_email.isEmpty() ) s2 += " " + i->m_email + "\n"; | |
398 if ( !i->m_weblink.isEmpty() ) s2 += " " + i->m_weblink + "\n"; | |
399 s2 += "\n"; | |
400 } | |
401 QTextBrowser* tb2 = new QTextBrowser(&d); | |
402 tb2->setWordWrap( QTextEdit::NoWrap ); | |
403 tb2->setText(s2); | |
404 d.addTab(tb2,i18n("A&uthor")); | |
405 | |
406 QString s3; | |
407 for( i=s_pAboutData->m_creditList.begin(); i!=s_pAboutData->m_creditList.end(); ++i ) | |
408 { | |
409 if ( !i->m_name.isEmpty() ) s3 += i->m_name + "\n"; | |
410 if ( !i->m_task.isEmpty() ) s3 += " " + i->m_task + "\n"; | |
411 if ( !i->m_email.isEmpty() ) s3 += " " + i->m_email + "\n"; | |
412 if ( !i->m_weblink.isEmpty() ) s3 += " " + i->m_weblink + "\n"; | |
413 s3 += "\n"; | |
414 } | |
415 QTextBrowser* tb3 = new QTextBrowser(&d); | |
416 tb3->setWordWrap( QTextEdit::NoWrap ); | |
417 tb3->setText(s3); | |
418 d.addTab(tb3,i18n("&Thanks To")); | |
419 | |
420 d.resize(400,300); | |
421 d.exec(); | |
422 /* | |
361 QMessageBox::information( | 423 QMessageBox::information( |
362 this, | 424 this, |
363 "About " + s_appName, | 425 "About " + s_appName, |
364 s_appName + " Version " + s_version + | 426 s_appName + " Version " + s_version + |
365 "\n\n" + s_description + | 427 "\n\n" + s_description + |
366 "\n\n" + s_copyright + | 428 "\n\n" + s_copyright + |
367 "\n\nHomepage: " + s_homepage + | 429 "\n\nHomepage: " + s_homepage + |
368 "\n\nLicence: GNU GPL Version 2" | 430 "\n\nLicence: GNU GPL Version 2" |
369 ); | 431 ); |
432 */ | |
370 } | 433 } |
371 | 434 |
372 void KMainWindow::slotHelp() | 435 void KMainWindow::slotHelp() |
373 { | 436 { |
374 showHelp(); | 437 showHelp(); |
514 //return s.section(',', idx, idx).toInt(); | 577 //return s.section(',', idx, idx).toInt(); |
515 } | 578 } |
516 | 579 |
517 void KConfig::writeEntry(const QString& k, const QFont& v ) | 580 void KConfig::writeEntry(const QString& k, const QFont& v ) |
518 { | 581 { |
519 //m_map[k] = v.toString(); | 582 m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal"); |
520 m_map[k] = v.family() + "," + QString::number(v.pointSize()); | |
521 } | 583 } |
522 | 584 |
523 void KConfig::writeEntry(const QString& k, const QColor& v ) | 585 void KConfig::writeEntry(const QString& k, const QColor& v ) |
524 { | 586 { |
525 m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue()); | 587 m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue()); |
562 std::map<QString,QString>::iterator i = m_map.find( k ); | 624 std::map<QString,QString>::iterator i = m_map.find( k ); |
563 if ( i!=m_map.end() ) | 625 if ( i!=m_map.end() ) |
564 { | 626 { |
565 f.setFamily( subSection( i->second, 0, ',' ) ); | 627 f.setFamily( subSection( i->second, 0, ',' ) ); |
566 f.setPointSize( subSection( i->second, 1, ',' ).toInt() ); | 628 f.setPointSize( subSection( i->second, 1, ',' ).toInt() ); |
629 f.setBold( subSection( i->second, 2, ',' )=="bold" ); | |
567 //f.fromString(i->second); | 630 //f.fromString(i->second); |
568 } | 631 } |
569 | 632 |
570 return f; | 633 return f; |
571 } | 634 } |
703 p->dirCurrentSyncItemMenu = new QPopupMenu(); | 766 p->dirCurrentSyncItemMenu = new QPopupMenu(); |
704 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu); | 767 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu); |
705 } | 768 } |
706 addTo( p->dirCurrentSyncItemMenu ); | 769 addTo( p->dirCurrentSyncItemMenu ); |
707 } | 770 } |
771 else if( name.left(4)=="diff") addTo( p->diffMenu ); | |
708 else if( name[0]=='d') addTo( p->directoryMenu ); | 772 else if( name[0]=='d') addTo( p->directoryMenu ); |
709 else if( name[0]=='f') addTo( p->fileMenu ); | 773 else if( name[0]=='f') addTo( p->fileMenu ); |
710 else if( name[0]=='w') addTo( p->windowsMenu ); | 774 else if( name[0]=='w') addTo( p->windowsMenu ); |
711 else addTo( p->mergeMenu ); | 775 else addTo( p->mergeMenu ); |
712 } | 776 } |
751 p->dirCurrentSyncItemMenu = new QPopupMenu(); | 815 p->dirCurrentSyncItemMenu = new QPopupMenu(); |
752 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu); | 816 p->directoryMenu->insertItem(i18n("Current Item Sync Operation"), p->dirCurrentSyncItemMenu); |
753 } | 817 } |
754 addTo( p->dirCurrentSyncItemMenu ); | 818 addTo( p->dirCurrentSyncItemMenu ); |
755 } | 819 } |
820 else if( name.left(4)=="diff") addTo( p->diffMenu ); | |
756 else if( name[0]=='d') addTo( p->directoryMenu ); | 821 else if( name[0]=='d') addTo( p->directoryMenu ); |
757 else if( name[0]=='f') addTo( p->fileMenu ); | 822 else if( name[0]=='f') addTo( p->fileMenu ); |
758 else if( name[0]=='w') addTo( p->windowsMenu ); | 823 else if( name[0]=='w') addTo( p->windowsMenu ); |
759 else addTo( p->mergeMenu ); | 824 else addTo( p->mergeMenu ); |
760 } | 825 } |
1033 | 1098 |
1034 KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ ) | 1099 KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ ) |
1035 { | 1100 { |
1036 } | 1101 } |
1037 | 1102 |
1038 void KAboutData::addAuthor(const QString& /*name*/, int, const QString& /*email*/) | 1103 void KAboutData::addAuthor(const char* name, const char* task, const char* email, const char* weblink) |
1039 { | 1104 { |
1105 m_authorList.push_back( AboutDataEntry( name, task, email, weblink) ); | |
1106 } | |
1107 | |
1108 void KAboutData::addCredit(const char* name, const char* task, const char* email, const char* weblink) | |
1109 { | |
1110 m_creditList.push_back( AboutDataEntry( name, task, email, weblink) ); | |
1040 } | 1111 } |
1041 | 1112 |
1042 /* Option structure: e.g.: | 1113 /* Option structure: e.g.: |
1043 { "m", 0, 0 }, | 1114 { "m", 0, 0 }, |
1044 { "merge", I18N_NOOP("Automatically merge the input."), 0 }, | 1115 { "merge", I18N_NOOP("Automatically merge the input."), 0 }, |
1060 KCmdLineArgs* KCmdLineArgs::parsedArgs() // static | 1131 KCmdLineArgs* KCmdLineArgs::parsedArgs() // static |
1061 { | 1132 { |
1062 return &s_cmdLineArgs; | 1133 return &s_cmdLineArgs; |
1063 } | 1134 } |
1064 | 1135 |
1065 void KCmdLineArgs::init( int argc, char**argv, KAboutData* ) // static | 1136 void KCmdLineArgs::init( int argc, char**argv, KAboutData* pAboutData ) // static |
1066 { | 1137 { |
1067 s_argc = argc; | 1138 s_argc = argc; |
1068 s_argv = argv; | 1139 s_argv = argv; |
1140 s_pAboutData = pAboutData; | |
1069 } | 1141 } |
1070 | 1142 |
1071 void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static | 1143 void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static |
1072 { | 1144 { |
1073 s_pOptions = options; | 1145 s_pOptions = options; |
1204 s += " Note that file1 will be treated as base of file2 and file3.\n"; | 1276 s += " Note that file1 will be treated as base of file2 and file3.\n"; |
1205 s += "\n"; | 1277 s += "\n"; |
1206 s += "If you start without arguments, then a dialog will appear\n"; | 1278 s += "If you start without arguments, then a dialog will appear\n"; |
1207 s += "where you can select your files via a filebrowser.\n"; | 1279 s += "where you can select your files via a filebrowser.\n"; |
1208 s += "\n"; | 1280 s += "\n"; |
1209 s += "For more documentation, see the help-menu or the subdirectory doc.\n"; | 1281 |
1282 s += "Options:\n"; | |
1283 | |
1284 j=0; | |
1285 int pos=s.length(); | |
1286 for( j=0; j<nofOptions; ++j ) | |
1287 { | |
1288 if ( s_pOptions[j].longName!=0 ) | |
1289 { | |
1290 if (s_pOptions[j].shortName[0]!='+') | |
1291 { | |
1292 s += "-"; | |
1293 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-"; | |
1294 } | |
1295 s += s_pOptions[j].shortName; | |
1296 s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) ); | |
1297 s += s_pOptions[j].longName; | |
1298 s +="\n"; | |
1299 pos=s.length(); | |
1300 } | |
1301 else | |
1302 { | |
1303 s += "-"; | |
1304 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-"; | |
1305 s += s_pOptions[j].shortName; | |
1306 s += ", "; | |
1307 } | |
1308 } | |
1309 | |
1310 s += "\nFor more documentation, see the help-menu or the subdirectory doc.\n"; | |
1210 #ifdef _WIN32 | 1311 #ifdef _WIN32 |
1211 // A windows program has no console | 1312 // A windows program has no console |
1212 KMessageBox::information(0, s,i18n("KDiff3-Usage")); | 1313 KMessageBox::information(0, s,i18n("KDiff3-Usage")); |
1213 #else | 1314 #else |
1214 std::cerr << s.latin1() << std::endl; | 1315 std::cerr << s.latin1() << std::endl; |