comparison kdiff3/src/optiondialog.cpp @ 70:5bbfe4784324

KDiff3 0.9.89 for Qt4
author joachim99
date Tue, 18 Apr 2006 20:19:57 +0000
parents 8febbfb1148c
children f7dad0aa6146
comparison
equal deleted inserted replaced
69:8febbfb1148c 70:5bbfe4784324
19 */ 19 */
20 20
21 #include <qcheckbox.h> 21 #include <qcheckbox.h>
22 #include <qcombobox.h> 22 #include <qcombobox.h>
23 #include <qfont.h> 23 #include <qfont.h>
24 #include <qframe.h> 24 #include <q3frame.h>
25 #include <qlayout.h> 25 #include <qlayout.h>
26 #include <qlabel.h> 26 #include <qlabel.h>
27 #include <qlineedit.h> 27 #include <qlineedit.h>
28 #include <qvbox.h> 28 #include <q3vbox.h>
29 #include <qvalidator.h> 29 #include <qvalidator.h>
30 #include <qtooltip.h> 30 #include <qtooltip.h>
31 #include <qtextcodec.h> 31 #include <qtextcodec.h>
32 #include <qradiobutton.h> 32 #include <qradiobutton.h>
33 #include <qvbuttongroup.h> 33 #include <Q3VButtonGroup>
34 //Added by qt3to4:
35 #include <Q3GridLayout>
36 #include <Q3VBoxLayout>
34 37
35 #include <kapplication.h> 38 #include <kapplication.h>
36 #include <kcolorbtn.h> 39 #include <kcolorbtn.h>
37 #include <kfontdialog.h> // For KFontChooser 40 #include <kfontdialog.h> // For KFontChooser
38 #include <kiconloader.h> 41 #include <kiconloader.h>
226 void setToDefault(){ setCurrentText( m_defaultVal ); } 229 void setToDefault(){ setCurrentText( m_defaultVal ); }
227 void setToCurrent(){ setCurrentText( *m_pVar ); } 230 void setToCurrent(){ setCurrentText( *m_pVar ); }
228 void apply() { *m_pVar = currentText(); insertText(); } 231 void apply() { *m_pVar = currentText(); insertText(); }
229 void write(ValueMap* config){ config->writeEntry( m_saveName, m_list, '|' ); } 232 void write(ValueMap* config){ config->writeEntry( m_saveName, m_list, '|' ); }
230 void read (ValueMap* config){ 233 void read (ValueMap* config){
231 m_list = config->readListEntry( m_saveName, m_defaultVal, '|' ); 234 m_list = config->readListEntry( m_saveName, QStringList(m_defaultVal), '|' );
232 if ( !m_list.empty() ) *m_pVar = m_list.front(); 235 if ( !m_list.empty() ) *m_pVar = m_list.front();
233 clear(); 236 clear();
234 insertStringList(m_list); 237 insertStringList(m_list);
235 } 238 }
236 private: 239 private:
239 QString current = currentText(); 242 QString current = currentText();
240 m_list.remove( current ); 243 m_list.remove( current );
241 m_list.push_front( current ); 244 m_list.push_front( current );
242 clear(); 245 clear();
243 if ( m_list.size()>10 ) 246 if ( m_list.size()>10 )
244 m_list.erase( m_list.at(10),m_list.end() ); 247 m_list.erase( m_list.begin()+10, m_list.end() );
245 insertStringList(m_list); 248 insertStringList(m_list);
246 } 249 }
247 OptionLineEdit( const OptionLineEdit& ); // private copy constructor without implementation 250 OptionLineEdit( const OptionLineEdit& ); // private copy constructor without implementation
248 QString* m_pVar; 251 QString* m_pVar;
249 QString m_defaultVal; 252 QString m_defaultVal;
362 insertCodec( i18n("Unicode"), QTextCodec::codecForName("iso-10646-UCS-2") ); 365 insertCodec( i18n("Unicode"), QTextCodec::codecForName("iso-10646-UCS-2") );
363 insertCodec( i18n("Latin1"), QTextCodec::codecForName("iso 8859-1") ); 366 insertCodec( i18n("Latin1"), QTextCodec::codecForName("iso 8859-1") );
364 367
365 // First sort codec names: 368 // First sort codec names:
366 std::map<QString, QTextCodec*> names; 369 std::map<QString, QTextCodec*> names;
367 int i; 370 QList<int> mibs = QTextCodec::availableMibs();
368 for(i=0;;++i) 371 foreach(int i, mibs)
369 { 372 {
370 QTextCodec* c = QTextCodec::codecForIndex(i); 373 QTextCodec* c = QTextCodec::codecForMib(i);
371 if ( c==0 ) break; 374 if ( c==0 ) break;
372 else names[QString(c->name()).upper()]=c; 375 else names[QString(c->name()).upper()]=c;
373 } 376 }
374 377
375 std::map<QString, QTextCodec*>::iterator it; 378 std::map<QString, QTextCodec*>::iterator it;
430 { 433 {
431 if (m_ppVarCodec!=0){ *m_ppVarCodec = m_codecVec[ currentItem() ]; } 434 if (m_ppVarCodec!=0){ *m_ppVarCodec = m_codecVec[ currentItem() ]; }
432 } 435 }
433 void write(ValueMap* config) 436 void write(ValueMap* config)
434 { 437 {
435 if (m_ppVarCodec!=0) config->writeEntry(m_saveName, (*m_ppVarCodec)->name() ); 438 if (m_ppVarCodec!=0) config->writeEntry(m_saveName, QString((*m_ppVarCodec)->name()) );
436 } 439 }
437 void read (ValueMap* config) 440 void read (ValueMap* config)
438 { 441 {
439 QString codecName = config->readEntry( m_saveName, m_codecVec[ currentItem() ]->name() ); 442 QString codecName = config->readEntry( m_saveName, m_codecVec[ currentItem() ]->name() );
440 for(unsigned int i=0; i<m_codecVec.size(); ++i) 443 for(unsigned int i=0; i<m_codecVec.size(); ++i)
502 new OptionStringList( "RecentOutputFiles", &m_recentOutputFiles, this ); 505 new OptionStringList( "RecentOutputFiles", &m_recentOutputFiles, this );
503 } 506 }
504 507
505 void OptionDialog::setupFontPage( void ) 508 void OptionDialog::setupFontPage( void )
506 { 509 {
507 QFrame *page = addPage( i18n("Font"), i18n("Editor & Diff Output Font" ), 510 Q3Frame *page = addPage( i18n("Font"), i18n("Editor & Diff Output Font" ),
508 BarIcon("fonts", KIcon::SizeMedium ) ); 511 BarIcon("fonts", KIcon::SizeMedium ) );
509 512
510 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 513 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
511 514
512 QFont defaultFont = 515 QFont defaultFont =
513 #ifdef _WIN32 516 #ifdef _WIN32
514 QFont("Courier New", 10 ); 517 QFont("Courier New", 10 );
515 #elif defined( KREPLACEMENTS_H ) 518 #elif defined( KREPLACEMENTS_H )
519 #endif 522 #endif
520 523
521 OptionFontChooser* pFontChooser = new OptionFontChooser( defaultFont, "Font", &m_font, page, this ); 524 OptionFontChooser* pFontChooser = new OptionFontChooser( defaultFont, "Font", &m_font, page, this );
522 topLayout->addWidget( pFontChooser ); 525 topLayout->addWidget( pFontChooser );
523 526
524 QGridLayout *gbox = new QGridLayout( 1, 2 ); 527 Q3GridLayout *gbox = new Q3GridLayout( 1, 2 );
525 topLayout->addLayout( gbox ); 528 topLayout->addLayout( gbox );
526 int line=0; 529 int line=0;
527 530
528 OptionCheckBox* pItalicDeltas = new OptionCheckBox( i18n("Italic font for deltas"), false, "ItalicForDeltas", &m_bItalicForDeltas, page, this ); 531 OptionCheckBox* pItalicDeltas = new OptionCheckBox( i18n("Italic font for deltas"), false, "ItalicForDeltas", &m_bItalicForDeltas, page, this );
529 gbox->addMultiCellWidget( pItalicDeltas, line, line, 0, 1 ); 532 gbox->addMultiCellWidget( pItalicDeltas, line, line, 0, 1 );
534 } 537 }
535 538
536 539
537 void OptionDialog::setupColorPage( void ) 540 void OptionDialog::setupColorPage( void )
538 { 541 {
539 QFrame *page = addPage( i18n("Color"), i18n("Colors Settings"), 542 Q3Frame *page = addPage( i18n("Color"), i18n("Colors Settings"),
540 BarIcon("colorize", KIcon::SizeMedium ) ); 543 BarIcon("colorize", KIcon::SizeMedium ) );
541 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 544 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
542 545
543 QGridLayout *gbox = new QGridLayout( 7, 2 ); 546 Q3GridLayout *gbox = new Q3GridLayout( 7, 2 );
544 gbox->setColStretch(1,5); 547 gbox->setColStretch(1,5);
545 topLayout->addLayout(gbox); 548 topLayout->addLayout(gbox);
546 549
547 QLabel* label; 550 QLabel* label;
548 int line = 0; 551 int line = 0;
549 552
550 int depth = QColor::numBitPlanes(); 553 int depth = QPixmap::defaultDepth();
551 bool bLowColor = depth<=8; 554 bool bLowColor = depth<=8;
552 555
553 label = new QLabel( i18n("Editor and Diff Views:"), page ); 556 label = new QLabel( i18n("Editor and Diff Views:"), page );
554 gbox->addWidget( label, line, 0 ); 557 gbox->addWidget( label, line, 0 );
555 QFont f( label->font() ); 558 QFont f( label->font() );
662 } 665 }
663 666
664 667
665 void OptionDialog::setupEditPage( void ) 668 void OptionDialog::setupEditPage( void )
666 { 669 {
667 QFrame *page = addPage( i18n("Editor"), i18n("Editor Behavior"), 670 Q3Frame *page = addPage( i18n("Editor"), i18n("Editor Behavior"),
668 BarIcon("edit", KIcon::SizeMedium ) ); 671 BarIcon("edit", KIcon::SizeMedium ) );
669 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 672 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
670 673
671 QGridLayout *gbox = new QGridLayout( 4, 2 ); 674 Q3GridLayout *gbox = new Q3GridLayout( 4, 2 );
672 gbox->setColStretch(1,5); 675 gbox->setColStretch(1,5);
673 topLayout->addLayout( gbox ); 676 topLayout->addLayout( gbox );
674 QLabel* label; 677 QLabel* label;
675 int line=0; 678 int line=0;
676 679
724 } 727 }
725 728
726 729
727 void OptionDialog::setupDiffPage( void ) 730 void OptionDialog::setupDiffPage( void )
728 { 731 {
729 QFrame *page = addPage( i18n("Diff and Merge"), i18n("Diff and Merge Settings"), 732 Q3Frame *page = addPage( i18n("Diff and Merge"), i18n("Diff and Merge Settings"),
730 BarIcon("misc", KIcon::SizeMedium ) ); 733 BarIcon("misc", KIcon::SizeMedium ) );
731 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 734 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
732 735
733 QGridLayout *gbox = new QGridLayout( 3, 2 ); 736 Q3GridLayout *gbox = new Q3GridLayout( 3, 2 );
734 gbox->setColStretch(1,5); 737 gbox->setColStretch(1,5);
735 topLayout->addLayout( gbox ); 738 topLayout->addLayout( gbox );
736 int line=0; 739 int line=0;
737 740
738 QLabel* label=0; 741 QLabel* label=0;
823 "Allow the merge algorithm to automatically select an input for " 826 "Allow the merge algorithm to automatically select an input for "
824 "white-space-only changes." ) 827 "white-space-only changes." )
825 ); 828 );
826 ++line; 829 ++line;
827 830
828 QGroupBox* pGroupBox = new QGroupBox( 2, Qt::Horizontal, i18n("Automatic Merge Regular Expression"), page); 831 Q3GroupBox* pGroupBox = new Q3GroupBox( 2, Qt::Horizontal, i18n("Automatic Merge Regular Expression"), page);
829 gbox->addMultiCellWidget( pGroupBox, line,line,0,1); 832 gbox->addMultiCellWidget( pGroupBox, line,line,0,1);
830 ++line; 833 ++line;
831 { 834 {
832 QWidget* page = new QWidget( pGroupBox ); 835 QWidget* page = new QWidget( pGroupBox );
833 QGridLayout* gbox = new QGridLayout( page, 2, 2, spacingHint() ); 836 Q3GridLayout* gbox = new Q3GridLayout( page, 2, 2, spacingHint() );
834 gbox->setColStretch(1,10); 837 gbox->setColStretch(1,10);
835 int line = 0; 838 int line = 0;
836 839
837 label = new QLabel( i18n("Auto merge regular expression:"), page ); 840 label = new QLabel( i18n("Auto merge regular expression:"), page );
838 gbox->addWidget( label, line, 0 ); 841 gbox->addWidget( label, line, 0 );
849 QToolTip::add( pAutoMergeRegExp, i18n( "Run the merge for auto merge regular expressions\n" 852 QToolTip::add( pAutoMergeRegExp, i18n( "Run the merge for auto merge regular expressions\n"
850 "immediately when a merge starts.\n")); 853 "immediately when a merge starts.\n"));
851 ++line; 854 ++line;
852 } 855 }
853 856
854 pGroupBox = new QGroupBox( 2, Qt::Horizontal, i18n("Version Control History Merging"), page); 857 pGroupBox = new Q3GroupBox( 2, Qt::Horizontal, i18n("Version Control History Merging"), page);
855 gbox->addMultiCellWidget( pGroupBox, line,line,0,1); 858 gbox->addMultiCellWidget( pGroupBox, line,line,0,1);
856 ++line; 859 ++line;
857 { 860 {
858 QWidget* page = new QWidget( pGroupBox ); 861 QWidget* page = new QWidget( pGroupBox );
859 QGridLayout* gbox = new QGridLayout( page, 2, 2, spacingHint() ); 862 Q3GridLayout* gbox = new Q3GridLayout( page, 2, 2, spacingHint() );
860 gbox->setColStretch(1,10); 863 gbox->setColStretch(1,10);
861 int line = 0; 864 int line = 0;
862 865
863 label = new QLabel( i18n("History start regular expression:"), page ); 866 label = new QLabel( i18n("History start regular expression:"), page );
864 gbox->addWidget( label, line, 0 ); 867 gbox->addWidget( label, line, 0 );
865 m_pHistoryStartRegExpLineEdit = new OptionLineEdit( ".*\\$Log.*\\$.*", "HistoryStartRegExp", &m_historyStartRegExp, page, this ); 868 m_pHistoryStartRegExpLineEdit = new OptionLineEdit( ".*\\$Log.*\\$.*", "HistoryStartRegExp", &m_historyStartRegExp, page, this );
866 gbox->addWidget( m_pHistoryStartRegExpLineEdit, line, 1 ); 869 gbox->addWidget( m_pHistoryStartRegExpLineEdit, line, 1 );
867 s_historyStartRegExpToolTip = i18n("Regular expression for the start of the version control history entry.\n" 870 s_historyStartRegExpToolTip = i18n("Regular expression for the start of the version control history entry.\n"
868 "Usually this line contains the \"$Log$ 871 "Usually this line contains the \"$Log$\"-keyword.\n"
869 "Usually this line contains the \"Revision 1.7 2006/04/10 08:37:33 joachim99
870 "Usually this line contains the \"KDiff3 0.9.89
871 "Usually this line contains the \"\"-keyword.\n"
872 "Default value: \".*\\$Log.*\\$.*\""); 872 "Default value: \".*\\$Log.*\\$.*\"");
873 QToolTip::add( label, s_historyStartRegExpToolTip ); 873 QToolTip::add( label, s_historyStartRegExpToolTip );
874 ++line; 874 ++line;
875 875
876 label = new QLabel( i18n("History entry start regular expression:"), page ); 876 label = new QLabel( i18n("History entry start regular expression:"), page );
943 topLayout->addStretch(10); 943 topLayout->addStretch(10);
944 } 944 }
945 945
946 void OptionDialog::setupDirectoryMergePage( void ) 946 void OptionDialog::setupDirectoryMergePage( void )
947 { 947 {
948 QFrame *page = addPage( i18n("Directory Merge"), i18n("Directory Merge"), 948 Q3Frame *page = addPage( i18n("Directory Merge"), i18n("Directory Merge"),
949 BarIcon("folder", KIcon::SizeMedium ) ); 949 BarIcon("folder", KIcon::SizeMedium ) );
950 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 950 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
951 951
952 QGridLayout *gbox = new QGridLayout( 11, 2 ); 952 Q3GridLayout *gbox = new Q3GridLayout( 11, 2 );
953 gbox->setColStretch(1,5); 953 gbox->setColStretch(1,5);
954 topLayout->addLayout( gbox ); 954 topLayout->addLayout( gbox );
955 int line=0; 955 int line=0;
956 956
957 OptionCheckBox* pRecursiveDirs = new OptionCheckBox( i18n("Recursive directories"), true, "RecursiveDirs", &m_bDmRecursiveDirs, page, this ); 957 OptionCheckBox* pRecursiveDirs = new OptionCheckBox( i18n("Recursive directories"), true, "RecursiveDirs", &m_bDmRecursiveDirs, page, this );
1040 QToolTip::add( pCaseSensitiveFileNames, i18n( 1040 QToolTip::add( pCaseSensitiveFileNames, i18n(
1041 "The directory comparison will compare files or directories when their names match.\n" 1041 "The directory comparison will compare files or directories when their names match.\n"
1042 "Set this option if the case of the names must match. (Default for Windows is off, otherwise on.)")); 1042 "Set this option if the case of the names must match. (Default for Windows is off, otherwise on.)"));
1043 ++line; 1043 ++line;
1044 1044
1045 QVButtonGroup* pBG = new QVButtonGroup(i18n("File Comparison Mode"),page); 1045 Q3VButtonGroup* pBG = new Q3VButtonGroup(i18n("File Comparison Mode"),page);
1046 gbox->addMultiCellWidget( pBG, line, line, 0, 1 ); 1046 gbox->addMultiCellWidget( pBG, line, line, 0, 1 );
1047 ++line; 1047 ++line;
1048 1048
1049 OptionRadioButton* pBinaryComparison = new OptionRadioButton( i18n("Binary comparison"), true, "BinaryComparison", &m_bDmBinaryComparison, pBG, this ); 1049 OptionRadioButton* pBinaryComparison = new OptionRadioButton( i18n("Binary comparison"), true, "BinaryComparison", &m_bDmBinaryComparison, pBG, this );
1050 QToolTip::add( pBinaryComparison, i18n("Binary comparison of each file. (Default)") ); 1050 QToolTip::add( pBinaryComparison, i18n("Binary comparison of each file. (Default)") );
1116 } 1116 }
1117 */ 1117 */
1118 1118
1119 void OptionDialog::setupRegionalPage( void ) 1119 void OptionDialog::setupRegionalPage( void )
1120 { 1120 {
1121 QFrame *page = addPage( i18n("Regional Settings"), i18n("Regional Settings"), 1121 Q3Frame *page = addPage( i18n("Regional Settings"), i18n("Regional Settings"),
1122 BarIcon("locale"/*"charset"*/, KIcon::SizeMedium ) ); 1122 BarIcon("locale"/*"charset"*/, KIcon::SizeMedium ) );
1123 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 1123 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
1124 1124
1125 QGridLayout *gbox = new QGridLayout( 3, 2 ); 1125 Q3GridLayout *gbox = new Q3GridLayout( 3, 2 );
1126 gbox->setColStretch(1,5); 1126 gbox->setColStretch(1,5);
1127 topLayout->addLayout( gbox ); 1127 topLayout->addLayout( gbox );
1128 int line=0; 1128 int line=0;
1129 1129
1130 QLabel* label; 1130 QLabel* label;
1316 topLayout->addStretch(10); 1316 topLayout->addStretch(10);
1317 } 1317 }
1318 1318
1319 void OptionDialog::setupIntegrationPage( void ) 1319 void OptionDialog::setupIntegrationPage( void )
1320 { 1320 {
1321 QFrame *page = addPage( i18n("Integration"), i18n("Integration Settings"), 1321 Q3Frame *page = addPage( i18n("Integration"), i18n("Integration Settings"),
1322 BarIcon("launch"/*"charset"*/, KIcon::SizeMedium ) ); 1322 BarIcon("launch"/*"charset"*/, KIcon::SizeMedium ) );
1323 QVBoxLayout *topLayout = new QVBoxLayout( page, 5, spacingHint() ); 1323 Q3VBoxLayout *topLayout = new Q3VBoxLayout( page, 5, spacingHint() );
1324 1324
1325 QGridLayout *gbox = new QGridLayout( 3, 2 ); 1325 Q3GridLayout *gbox = new Q3GridLayout( 3, 2 );
1326 gbox->setColStretch(1,5); 1326 gbox->setColStretch(1,5);
1327 topLayout->addLayout( gbox ); 1327 topLayout->addLayout( gbox );
1328 int line=0; 1328 int line=0;
1329 1329
1330 QLabel* label; 1330 QLabel* label;
1570 m_pHistorySortKeyOrderLineEdit->setCurrentText( dlg.historySortKeyOrder() ); 1570 m_pHistorySortKeyOrderLineEdit->setCurrentText( dlg.historySortKeyOrder() );
1571 } 1571 }
1572 } 1572 }
1573 1573
1574 1574
1575 #include "optiondialog.moc" 1575 //#include "optiondialog.moc"