comparison kdiff3/src/kreplacements/kreplacements.cpp @ 69:8febbfb1148c

KDiff3 0.9.89
author joachim99
date Mon, 10 Apr 2006 08:40:51 +0000
parents d7cafcda8c99
children 5bbfe4784324
comparison
equal deleted inserted replaced
68:d7cafcda8c99 69:8febbfb1148c
1 /*************************************************************************** 1 /***************************************************************************
2 kreplacements.cpp - description 2 kreplacements.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat Aug 3 2002 4 begin : Sat Aug 3 2002
5 copyright : (C) 2002-2003 by Joachim Eibl 5 copyright : (C) 2002-2006 by Joachim Eibl
6 email : joachim.eibl@gmx.de 6 email : joachim.eibl at gmx.de
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9 /*************************************************************************** 9 /***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
273 QWidget * parent, 273 QWidget * parent,
274 const QString & caption) 274 const QString & caption)
275 { 275 {
276 QString s = QFileDialog::getExistingDirectory(startDir, parent, 0, caption); 276 QString s = QFileDialog::getExistingDirectory(startDir, parent, 0, caption);
277 return KURL(s); 277 return KURL(s);
278 }
279
280 QString KFileDialog::getSaveFileName (const QString &startDir,
281 const QString &filter,
282 QWidget *parent,
283 const QString &caption)
284 {
285 return QFileDialog::getSaveFileName( startDir, filter, parent, 0, caption );
278 } 286 }
279 287
280 288
281 KToolBar::BarPosition KToolBar::barPos() 289 KToolBar::BarPosition KToolBar::barPos()
282 { 290 {
328 336
329 m_pToolBar = new KToolBar(this); 337 m_pToolBar = new KToolBar(this);
330 338
331 memberList = new QList<KMainWindow>; 339 memberList = new QList<KMainWindow>;
332 memberList->append(this); 340 memberList->append(this);
333 connect( qApp, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
334 }
335
336 void KMainWindow::closeEvent(QCloseEvent*e)
337 {
338 if ( queryClose() )
339 {
340 e->accept();
341 }
342 else
343 e->ignore();
344 }
345
346 bool KMainWindow::event( QEvent* e )
347 {
348 return QMainWindow::event(e);
349 } 341 }
350 342
351 KToolBar* KMainWindow::toolBar(const QString&) 343 KToolBar* KMainWindow::toolBar(const QString&)
352 { 344 {
353 return m_pToolBar; 345 return m_pToolBar;
360 352
361 void KMainWindow::createGUI() 353 void KMainWindow::createGUI()
362 { 354 {
363 KStdAction::help(this, SLOT(slotHelp()), actionCollection()); 355 KStdAction::help(this, SLOT(slotHelp()), actionCollection());
364 KStdAction::about(this, SLOT(slotAbout()), actionCollection()); 356 KStdAction::about(this, SLOT(slotAbout()), actionCollection());
365 } 357 KStdAction::aboutQt(actionCollection());
366
367 void KMainWindow::quit()
368 {
369 if ( queryExit() )
370 {
371 qApp->quit();
372 }
373 } 358 }
374 359
375 void KMainWindow::slotAbout() 360 void KMainWindow::slotAbout()
376 { 361 {
377 QTabDialog d; 362 QTabDialog d;
435 void KMainWindow::slotHelp() 420 void KMainWindow::slotHelp()
436 { 421 {
437 showHelp(); 422 showHelp();
438 } 423 }
439 424
425
426 QString KStandardDirs::findResource(const QString& resource, const QString& /*appName*/)
427 {
428 if (resource=="config")
429 {
430 QString home = QDir::homeDirPath();
431 return home + "/.kdiff3rc";
432 }
433 return QString();
434 }
435
440 KConfig::KConfig() 436 KConfig::KConfig()
441 { 437 {
442 QString home = QDir::homeDirPath(); 438 }
443 m_fileName = home + "/.kdiff3rc"; 439
440 void KConfig::readConfigFile( const QString& configFileName )
441 {
442 if ( !configFileName.isEmpty() )
443 {
444 m_fileName = configFileName;
445 }
446 else
447 {
448 m_fileName = KStandardDirs().findResource("config","kdiff3rc");
449 }
444 450
445 QFile f( m_fileName ); 451 QFile f( m_fileName );
446 if ( f.open(IO_ReadOnly) ) 452 if ( f.open(IO_ReadOnly) )
447 { // file opened successfully 453 { // file opened successfully
448 QTextStream t( &f ); // use a text stream 454 QTextStream t( &f ); // use a text stream
449 while ( !t.eof() ) 455 load(t);
450 { // until end of file...
451 QString s = t.readLine(); // line of text excluding '\n'
452 int pos = s.find('=');
453 if( pos > 0 ) // seems not to have a tag
454 {
455 QString key = s.left(pos);
456 QString val = s.mid(pos+1);
457 m_map[key] = val;
458 }
459 }
460 f.close(); 456 f.close();
461 } 457 }
462 } 458 }
463 459
464 KConfig::~KConfig() 460 KConfig::~KConfig()
465 { 461 {
466 QFile f(m_fileName); 462 QFile f(m_fileName);
467 if ( f.open( IO_WriteOnly | IO_Translate ) ) 463 if ( f.open( IO_WriteOnly | IO_Translate ) )
468 { // file opened successfully 464 { // file opened successfully
469 QTextStream t( &f ); // use a text stream 465 QTextStream t( &f ); // use a text stream
470 std::map<QString,QString>::iterator i; 466 save(t);
471 for( i=m_map.begin(); i!=m_map.end(); ++i)
472 {
473 QString key = i->first;
474 QString val = i->second;
475 t << key << "=" << val << "\n";
476 }
477 f.close(); 467 f.close();
478 } 468 }
479 } 469 }
480 470
481 void KConfig::setGroup(const QString&) 471 void KConfig::setGroup(const QString&)
482 { 472 {
483 }
484
485 // safeStringJoin and safeStringSplit allow to convert a stringlist into a string and back
486 // safely, even if the individual strings in the list contain the separator character.
487 static QString safeStringJoin(const QStringList& sl, char sepChar=',', char metaChar='\\' )
488 {
489 // Join the strings in the list, using the separator ','
490 // If a string contains the separator character, it will be replaced with "\,".
491 // Any occurances of "\" (one backslash) will be replaced with "\\" (2 backslashes)
492
493 assert(sepChar!=metaChar);
494
495 QString sep;
496 sep += sepChar;
497 QString meta;
498 meta += metaChar;
499
500 QString safeString;
501
502 QStringList::const_iterator i;
503 for (i=sl.begin(); i!=sl.end(); ++i)
504 {
505 QString s = *i;
506 s.replace(meta, meta+meta); // "\" -> "\\"
507 s.replace(sep, meta+sep); // "," -> "\,"
508 if ( i==sl.begin() )
509 safeString = s;
510 else
511 safeString += sep + s;
512 }
513 return safeString;
514 }
515
516 // Split a string that was joined with safeStringJoin
517 static QStringList safeStringSplit(const QString& s, char sepChar=',', char metaChar='\\' )
518 {
519 assert(sepChar!=metaChar);
520 QStringList sl;
521 // Miniparser
522 int i=0;
523 int len=s.length();
524 QString b;
525 for(i=0;i<len;++i)
526 {
527 if ( i+1<len && s[i]==metaChar && s[i+1]==metaChar ){ b+=metaChar; ++i; }
528 else if ( i+1<len && s[i]==metaChar && s[i+1]==sepChar ){ b+=sepChar; ++i; }
529 else if ( s[i]==sepChar ) // real separator
530 {
531 sl.push_back(b);
532 b="";
533 }
534 else { b+=s[i]; }
535 }
536 if ( !b.isEmpty() )
537 sl.push_back(b);
538
539 return sl;
540 }
541
542
543
544 static QString numStr(int n)
545 {
546 QString s;
547 s.setNum( n );
548 return s;
549 }
550
551 static QString subSection( const QString& s, int idx, char sep )
552 {
553 int pos=0;
554 while( idx>0 )
555 {
556 pos = s.find( sep, pos );
557 --idx;
558 if (pos<0) break;
559 ++pos;
560 }
561 if ( pos>=0 )
562 {
563 int pos2 = s.find( sep, pos );
564 if ( pos2>0 )
565 return s.mid(pos, pos2-pos);
566 else
567 return s.mid(pos);
568 }
569
570 return "";
571 }
572
573 static int num( QString& s, int idx )
574 {
575 return subSection( s, idx, ',').toInt();
576
577 //return s.section(',', idx, idx).toInt();
578 }
579
580 void KConfig::writeEntry(const QString& k, const QFont& v )
581 {
582 m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
583 }
584
585 void KConfig::writeEntry(const QString& k, const QColor& v )
586 {
587 m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
588 }
589
590 void KConfig::writeEntry(const QString& k, const QSize& v )
591 {
592 m_map[k] = numStr(v.width()) + "," + numStr(v.height());
593 }
594
595 void KConfig::writeEntry(const QString& k, const QPoint& v )
596 {
597 m_map[k] = numStr(v.x()) + "," + numStr(v.y());
598 }
599
600 void KConfig::writeEntry(const QString& k, int v )
601 {
602 m_map[k] = numStr(v);
603 }
604
605 void KConfig::writeEntry(const QString& k, bool v )
606 {
607 m_map[k] = numStr(v);
608 }
609
610 void KConfig::writeEntry(const QString& k, const QString& v )
611 {
612 m_map[k] = v;
613 }
614
615 void KConfig::writeEntry(const QString& k, const QStringList& v, char separator )
616 {
617 m_map[k] = safeStringJoin(v, separator);
618 }
619
620
621 QFont KConfig::readFontEntry(const QString& k, QFont* defaultVal )
622 {
623 QFont f = *defaultVal;
624 std::map<QString,QString>::iterator i = m_map.find( k );
625 if ( i!=m_map.end() )
626 {
627 f.setFamily( subSection( i->second, 0, ',' ) );
628 f.setPointSize( subSection( i->second, 1, ',' ).toInt() );
629 f.setBold( subSection( i->second, 2, ',' )=="bold" );
630 //f.fromString(i->second);
631 }
632
633 return f;
634 }
635
636 QColor KConfig::readColorEntry(const QString& k, QColor* defaultVal )
637 {
638 QColor c= *defaultVal;
639 std::map<QString,QString>::iterator i = m_map.find( k );
640 if ( i!=m_map.end() )
641 {
642 QString s = i->second;
643 c = QColor( num(s,0),num(s,1),num(s,2) );
644 }
645
646 return c;
647 }
648
649 QSize KConfig::readSizeEntry(const QString& k)
650 {
651 QSize size(640,400);
652 std::map<QString,QString>::iterator i = m_map.find( k );
653 if ( i!=m_map.end() )
654 {
655
656 QString s = i->second;
657 size = QSize( num(s,0),num(s,1) );
658 }
659
660 return size;
661 }
662
663 QPoint KConfig::readPointEntry(const QString& k)
664 {
665 QPoint point(0,0);
666 std::map<QString,QString>::iterator i = m_map.find( k );
667 if ( i!=m_map.end() )
668 {
669 QString s = i->second;
670 point = QPoint( num(s,0),num(s,1) );
671 }
672
673 return point;
674 }
675
676 bool KConfig::readBoolEntry(const QString& k, bool bDefault )
677 {
678 bool b = bDefault;
679 std::map<QString,QString>::iterator i = m_map.find( k );
680 if ( i!=m_map.end() )
681 {
682 QString s = i->second;
683 b = (bool)num(s,0);
684 }
685
686 return b;
687 }
688
689 int KConfig::readNumEntry(const QString& k, int iDefault )
690 {
691 int ival = iDefault;
692 std::map<QString,QString>::iterator i = m_map.find( k );
693 if ( i!=m_map.end() )
694 {
695 QString s = i->second;
696 ival = num(s,0);
697 }
698
699 return ival;
700 }
701
702 QString KConfig::readEntry(const QString& k, const QString& sDefault )
703 {
704 QString sval = sDefault;
705 std::map<QString,QString>::iterator i = m_map.find( k );
706 if ( i!=m_map.end() )
707 {
708 sval = i->second;
709 }
710
711 return sval;
712 }
713
714 QStringList KConfig::readListEntry(const QString& k, char separator )
715 {
716 QStringList strList;
717
718 std::map<QString,QString>::iterator i = m_map.find( k );
719 if ( i!=m_map.end() )
720 {
721 strList = safeStringSplit( i->second, separator );
722 }
723 return strList;
724 } 473 }
725 474
726 void KAction::init(QObject* receiver, const char* slot, KActionCollection* actionCollection, 475 void KAction::init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
727 const char* name, bool bToggle, bool bMenu) 476 const char* name, bool bToggle, bool bMenu)
728 { 477 {
857 KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false); 606 KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false);
858 if(p) a->addTo( p->fileMenu ); 607 if(p) a->addTo( p->fileMenu );
859 return a; 608 return a;
860 } 609 }
861 610
611 KAction* KStdAction::print( QWidget* parent, const char* slot, KActionCollection* actionCollection)
612 {
613 #include "../xpm/fileprint.xpm"
614 KMainWindow* p = actionCollection->m_pMainWindow;
615 KAction* a = new KAction( i18n("Print..."), QIconSet(QPixmap(fileprint)),Qt::CTRL+Qt::Key_P, parent, slot, actionCollection, "print", false, false);
616 if(p) a->addTo( p->fileMenu );
617 return a;
618 }
619
862 KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection) 620 KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection)
863 { 621 {
864 KMainWindow* p = actionCollection->m_pMainWindow; 622 KMainWindow* p = actionCollection->m_pMainWindow;
865 KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false); 623 KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false);
866 if(p) a->addTo( p->fileMenu ); 624 if(p) a->addTo( p->fileMenu );
889 KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false ); 647 KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false );
890 if(p) a->addTo( p->editMenu ); 648 if(p) a->addTo( p->editMenu );
891 return a; 649 return a;
892 } 650 }
893 651
652 KAction* KStdAction::selectAll( QWidget* parent, const char* slot, KActionCollection* actionCollection)
653 {
654 KMainWindow* p = actionCollection->m_pMainWindow;
655 KAction* a = new KAction( i18n("Select All"), Qt::CTRL+Qt::Key_A, parent, slot, actionCollection, "selectall", false, false );
656 if(p) a->addTo( p->editMenu );
657 return a;
658 }
659
894 KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection) 660 KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
895 { 661 {
896 KMainWindow* p = actionCollection->m_pMainWindow; 662 KMainWindow* p = actionCollection->m_pMainWindow;
897 KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false ); 663 KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false );
898 if(p) a->addTo( p->settingsMenu ); 664 if(p) a->addTo( p->settingsMenu );
920 } 686 }
921 687
922 KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection) 688 KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection)
923 { 689 {
924 KMainWindow* p = actionCollection->m_pMainWindow; 690 KMainWindow* p = actionCollection->m_pMainWindow;
925 KAction* a = new KAction( i18n("About"), 0, parent, slot, actionCollection, "about", false, false ); 691 KAction* a = new KAction( i18n("About")+" KDiff3", 0, parent, slot, actionCollection, "about_kdiff3", false, false );
692 if(p) a->addTo( p->helpMenu );
693 return a;
694 }
695
696 KAction* KStdAction::aboutQt( KActionCollection* actionCollection )
697 {
698 KMainWindow* p = actionCollection->m_pMainWindow;
699 KAction* a = new KAction( i18n("About")+" Qt", 0, qApp, SLOT(aboutQt()), actionCollection, "about_qt", false, false );
926 if(p) a->addTo( p->helpMenu ); 700 if(p) a->addTo( p->helpMenu );
927 return a; 701 return a;
928 } 702 }
929 703
930 KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection) 704 KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection)
1044 // Under Windows ChooseColor() should be used. (Nicer if few colors exist.) 818 // Under Windows ChooseColor() should be used. (Nicer if few colors exist.)
1045 QColor c = QColorDialog::getColor ( m_color, this ); 819 QColor c = QColorDialog::getColor ( m_color, this );
1046 if ( c.isValid() ) m_color = c; 820 if ( c.isValid() ) m_color = c;
1047 update(); 821 update();
1048 } 822 }
823
824 KPrinter::KPrinter()
825 {
826 }
827 QValueList<int> KPrinter::pageList()
828 {
829 QValueList<int> vl;
830 int to = toPage();
831 for(int i=fromPage(); i<=to; ++i)
832 {
833 vl.push_back(i);
834 }
835 return vl;
836 }
837 void KPrinter::setCurrentPage(int)
838 {
839 }
840 void KPrinter::setPageSelection(e_PageSelection)
841 {
842 }
843
1049 844
1050 QPixmap KIconLoader::loadIcon( const QString&, int ) 845 QPixmap KIconLoader::loadIcon( const QString&, int )
1051 { 846 {
1052 return QPixmap(); 847 return QPixmap();
1053 } 848 }
1131 { 926 {
1132 // Find the option 927 // Find the option
1133 int j=0; 928 int j=0;
1134 for( j=0; j<(int)s_vOption.size(); ++j ) 929 for( j=0; j<(int)s_vOption.size(); ++j )
1135 { 930 {
1136 const char* optName = s_pOptions[j].shortName; 931 const char* optName = s_pOptions[j].name;
1137 const char* pos = strchr( optName,' ' ); 932 const char* pos = strchr( optName,' ' );
1138 int len = pos==0 ? strlen( optName ) : pos - optName; 933 int len = pos==0 ? strlen( optName ) : pos - optName;
1139 934
1140 if( s == (const char*)( QCString( optName, len+1) ) ) 935 if( s == (const char*)( QCString( optName, len+1) ) )
1141 { 936 {
1150 { 945 {
1151 // Find the option 946 // Find the option
1152 int j=0; 947 int j=0;
1153 for( j=0; j<(int)s_vOption.size(); ++j ) 948 for( j=0; j<(int)s_vOption.size(); ++j )
1154 { 949 {
1155 const char* optName = s_pOptions[j].shortName; 950 const char* optName = s_pOptions[j].name;
1156 const char* pos = strchr( optName,' ' ); 951 const char* pos = strchr( optName,' ' );
1157 int len = pos==0 ? strlen( optName ) : pos - optName; 952 int len = pos==0 ? strlen( optName ) : pos - optName;
1158 953
1159 if( s == (const char*)( QCString( optName, len+1) ) ) 954 if( s == (const char*)( QCString( optName, len+1) ) )
1160 { 955 {
1170 { 965 {
1171 // Find the option 966 // Find the option
1172 int j=0; 967 int j=0;
1173 for( j=0; j<(int)s_vOption.size(); ++j ) 968 for( j=0; j<(int)s_vOption.size(); ++j )
1174 { 969 {
1175 const char* optName = s_pOptions[j].shortName; 970 const char* optName = s_pOptions[j].name;
1176 if( s == QString( optName ) ) 971 if( s == QString( optName ) )
1177 { 972 {
1178 return ! s_vOption[j].isEmpty(); 973 return ! s_vOption[j].isEmpty();
1179 } 974 }
1180 } 975 }
1191 kapp = this; 986 kapp = this;
1192 987
1193 int nofOptions=0; 988 int nofOptions=0;
1194 int nofArgs=0; 989 int nofArgs=0;
1195 int i=0; 990 int i=0;
1196 while( s_pOptions[i].shortName != 0 ) 991 while( s_pOptions[i].name != 0 )
1197 { 992 {
1198 if ( s_pOptions[i].shortName[0]=='[' ) 993 if ( s_pOptions[i].name[0]=='[' )
1199 nofArgs++; 994 nofArgs++;
1200 else 995 else
1201 nofOptions++; 996 nofOptions++;
1202 997
1203 ++i; 998 ++i;
1204 } 999 }
1205 1000
1001 // First find the option "-config" or "--config" to allow loading of options
1002 QString configFileName;
1003 for( i=1; i<s_argc-1; ++i )
1004 {
1005 QString arg = s_argv[i];
1006 if ( arg == "-config" || arg == "--config" )
1007 {
1008 configFileName = s_argv[i+1];
1009 }
1010 }
1011 m_config.readConfigFile(configFileName);
1012
1013 QStringList ignorableCmdLineOptionsList = m_config.readListEntry("IgnorableCmdLineOptions", QString("-u;-query;-html;-abort"), '|');
1014 QString ignorableCmdLineOptions;
1015 if ( !ignorableCmdLineOptionsList.isEmpty() )
1016 ignorableCmdLineOptions = ignorableCmdLineOptionsList.front() + ";";
1017
1206 s_vOption.resize(nofOptions); 1018 s_vOption.resize(nofOptions);
1207 1019
1208 for( i=1; i<s_argc; ++i ) 1020 for( i=1; i<s_argc; ++i )
1209 { 1021 {
1210 if ( s_argv[i][0]=='-' ) // An option 1022 if ( s_argv[i][0]=='-' ) // An option
1211 { 1023 {
1024 if ( ignorableCmdLineOptions.contains(QString(s_argv[i])+";") )
1025 continue;
1212 // Find the option 1026 // Find the option
1213 int j=0; 1027 int j=0;
1214 for( j=0; j<nofOptions; ++j ) 1028 for( j=0; j<nofOptions; ++j )
1215 { 1029 {
1216 const char* optName = s_pOptions[j].shortName; 1030 const char* optName = s_pOptions[j].name;
1217 const char* pos = strchr( optName,' ' ); 1031 const char* pos = strchr( optName,' ' );
1218 int len = pos==0 ? strlen( optName ) : pos - optName; 1032 int len = pos==0 ? strlen( optName ) : pos - optName;
1219 1033 int len2 = strlen(s_argv[i]);
1220 if( len>0 && ( s_argv[i][1]=='-' && memcmp( &s_argv[i][2], optName, len )==0 || 1034
1221 memcmp( &s_argv[i][1], optName, len )==0 )) 1035 if( len>0 && ( s_argv[i][1]=='-' && len2-2==len && memcmp( &s_argv[i][2], optName, len )==0 ||
1036 len2-1==len && memcmp( &s_argv[i][1], optName, len )==0 ))
1222 { 1037 {
1223 if (s_pOptions[j].longName == 0) // alias, because without description. 1038 if (s_pOptions[j].description == 0) // alias, because without description.
1224 { 1039 {
1225 ++j; 1040 ++j;
1226 optName = s_pOptions[j].shortName; 1041 optName = s_pOptions[j].name;
1227 pos = strchr( optName,' ' ); 1042 pos = strchr( optName,' ' );
1228 } 1043 }
1229 if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param 1044 if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param
1230 else { s_vOption[j].append("1"); } //set state 1045 else { s_vOption[j].append("1"); } //set state
1231 break; 1046 break;
1233 } 1048 }
1234 if (j==nofOptions) 1049 if (j==nofOptions)
1235 { 1050 {
1236 QString s; 1051 QString s;
1237 s = QString("Unknown option: ") + s_argv[i] + "\n"; 1052 s = QString("Unknown option: ") + s_argv[i] + "\n";
1053 s += "If KDiff3 should ignore this option, run KDiff3 normally and edit\n"
1054 "the \"Command line options to ignore\" in the \"Integration Settings\".\n\n";
1238 1055
1239 s += "KDiff3-Usage when starting via commandline: \n"; 1056 s += "KDiff3-Usage when starting via commandline: \n";
1240 s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n"; 1057 s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n";
1241 s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n"; 1058 s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n";
1242 s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n"; 1059 s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n";
1251 1068
1252 j=0; 1069 j=0;
1253 int pos=s.length(); 1070 int pos=s.length();
1254 for( j=0; j<nofOptions; ++j ) 1071 for( j=0; j<nofOptions; ++j )
1255 { 1072 {
1256 if ( s_pOptions[j].longName!=0 ) 1073 if ( s_pOptions[j].description!=0 )
1257 { 1074 {
1258 if (s_pOptions[j].shortName[0]!='+') 1075 if (s_pOptions[j].name[0]!='+')
1259 { 1076 {
1260 s += "-"; 1077 s += "-";
1261 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-"; 1078 if ( strlen(s_pOptions[j].name)>1 ) s += "-";
1262 } 1079 }
1263 s += s_pOptions[j].shortName; 1080 s += s_pOptions[j].name;
1264 s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) ); 1081 s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) );
1265 s += s_pOptions[j].longName; 1082 s += s_pOptions[j].description;
1266 s +="\n"; 1083 s +="\n";
1267 pos=s.length(); 1084 pos=s.length();
1268 } 1085 }
1269 else 1086 else
1270 { 1087 {
1271 s += "-"; 1088 s += "-";
1272 if ( strlen(s_pOptions[j].shortName)>1 ) s += "-"; 1089 if ( strlen(s_pOptions[j].name)>1 ) s += "-";
1273 s += s_pOptions[j].shortName; 1090 s += s_pOptions[j].name;
1274 s += ", "; 1091 s += ", ";
1275 } 1092 }
1276 } 1093 }
1277 1094
1278 s += "\nFor more documentation, see the help-menu or the subdirectory doc.\n"; 1095 s += "\n"+i18n("For more documentation, see the help-menu or the subdirectory doc.")+"\n";
1279 #ifdef _WIN32 1096 #ifdef _WIN32
1280 // A windows program has no console 1097 // A windows program has no console
1281 KMessageBox::information(0, s,i18n("KDiff3-Usage")); 1098 if ( 0==QMessageBox::information(0, i18n("KDiff3-Usage"), s, i18n("Ignore"),i18n("Exit") ) )
1099 continue;
1282 #else 1100 #else
1283 std::cerr << s.latin1() << std::endl; 1101 std::cerr << s.latin1() << std::endl;
1284 #endif 1102 #endif
1285 1103
1286 ::exit(-1); 1104 ::exit(-1);
1287 } 1105 }
1288 } 1106 }
1289 else 1107 else
1290 s_vArg.push_back( s_argv[i] ); 1108 s_vArg.push_back( s_argv[i] );