comparison kdiff3/src-QT4/smalldialogs.cpp @ 80:fcd146072e0c

0.9.93
author joachim99
date Tue, 06 Jan 2009 17:51:29 +0000
parents 1184fc843210
children 236f1c9c3fbf
comparison
equal deleted inserted replaced
79:881e47f5076b 80:fcd146072e0c
30 #include <QToolTip> 30 #include <QToolTip>
31 #include <QUrl> 31 #include <QUrl>
32 #include <QDir> 32 #include <QDir>
33 #include <QDropEvent> 33 #include <QDropEvent>
34 #include <QMenu> 34 #include <QMenu>
35 #include <QPushButton>
35 36
36 #include <kfiledialog.h> 37 #include <kfiledialog.h>
37 #include <klocale.h> 38 #include <klocale.h>
38 39
39 // OpenDialog ************************************************************** 40 // OpenDialog **************************************************************
57 QLabel* label = new QLabel( i18n("A (Base):"), this ); 58 QLabel* label = new QLabel( i18n("A (Base):"), this );
58 59
59 m_pLineA = new QComboBox(); 60 m_pLineA = new QComboBox();
60 m_pLineA->setEditable(true); 61 m_pLineA->setEditable(true);
61 m_pLineA->insertItems( 0, m_pOptions->m_recentAFiles ); 62 m_pLineA->insertItems( 0, m_pOptions->m_recentAFiles );
62 m_pLineA->setEditText( KURL(n1).prettyURL() ); 63 m_pLineA->setEditText( KUrl(n1).prettyUrl() );
63 m_pLineA->setMinimumWidth( 200 ); 64 m_pLineA->setMinimumWidth( 200 );
64 QPushButton * button = new QPushButton( i18n("File..."), this ); 65 QPushButton * button = new QPushButton( i18n("File..."), this );
65 connect( button, SIGNAL(clicked()), this, SLOT( selectFileA() ) ); 66 connect( button, SIGNAL(clicked()), this, SLOT( selectFileA() ) );
66 QPushButton * button2 = new QPushButton( i18n("Dir..."), this ); 67 QPushButton * button2 = new QPushButton( i18n("Dir..."), this );
67 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirA() ) ); 68 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirA() ) );
74 75
75 label = new QLabel( "B:", this ); 76 label = new QLabel( "B:", this );
76 m_pLineB = new QComboBox(); 77 m_pLineB = new QComboBox();
77 m_pLineB->setEditable(true); 78 m_pLineB->setEditable(true);
78 m_pLineB->insertItems( 0, m_pOptions->m_recentBFiles ); 79 m_pLineB->insertItems( 0, m_pOptions->m_recentBFiles );
79 m_pLineB->setEditText( KURL(n2).prettyURL() ); 80 m_pLineB->setEditText( KUrl(n2).prettyUrl() );
80 m_pLineB->setMinimumWidth( 200 ); 81 m_pLineB->setMinimumWidth( 200 );
81 button = new QPushButton( i18n("File..."), this ); 82 button = new QPushButton( i18n("File..."), this );
82 connect( button, SIGNAL(clicked()), this, SLOT( selectFileB() ) ); 83 connect( button, SIGNAL(clicked()), this, SLOT( selectFileB() ) );
83 button2 = new QPushButton( i18n("Dir..."), this ); 84 button2 = new QPushButton( i18n("Dir..."), this );
84 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirB() ) ); 85 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirB() ) );
91 92
92 label = new QLabel( i18n("C (Optional):"), this ); 93 label = new QLabel( i18n("C (Optional):"), this );
93 m_pLineC= new QComboBox(); 94 m_pLineC= new QComboBox();
94 m_pLineC->setEditable(true); 95 m_pLineC->setEditable(true);
95 m_pLineC->insertItems( 0, m_pOptions->m_recentCFiles ); 96 m_pLineC->insertItems( 0, m_pOptions->m_recentCFiles );
96 m_pLineC->setEditText( KURL(n3).prettyURL() ); 97 m_pLineC->setEditText( KUrl(n3).prettyUrl() );
97 m_pLineC->setMinimumWidth( 200 ); 98 m_pLineC->setMinimumWidth( 200 );
98 button = new QPushButton( i18n("File..."), this ); 99 button = new QPushButton( i18n("File..."), this );
99 connect( button, SIGNAL(clicked()), this, SLOT( selectFileC() ) ); 100 connect( button, SIGNAL(clicked()), this, SLOT( selectFileC() ) );
100 button2 = new QPushButton( i18n("Dir..."), this ); 101 button2 = new QPushButton( i18n("Dir..."), this );
101 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirC() ) ); 102 connect( button2, SIGNAL(clicked()), this, SLOT( selectDirC() ) );
115 button = new QPushButton(i18n("Swap/Copy Names ..."), this); 116 button = new QPushButton(i18n("Swap/Copy Names ..."), this);
116 //button->setToggleButton(false); 117 //button->setToggleButton(false);
117 hl->addWidget( button ); 118 hl->addWidget( button );
118 119
119 QMenu* m = new QMenu(this); 120 QMenu* m = new QMenu(this);
120 m->addAction( i18n("Swap %1<->%2").arg("A").arg("B") ); 121 m->addAction( i18n("Swap %1<->%2", QString("A"),QString("B") ));
121 m->addAction( i18n("Swap %1<->%2").arg("B").arg("C") ); 122 m->addAction( i18n("Swap %1<->%2",QString("B"),QString("C") ));
122 m->addAction( i18n("Swap %1<->%2").arg("C").arg("A") ); 123 m->addAction( i18n("Swap %1<->%2",QString("C"),QString("A") ));
123 m->addAction( i18n("Copy %1->Output").arg("A") ); 124 m->addAction( i18n("Copy %1->Output",QString("A") ));
124 m->addAction( i18n("Copy %1->Output").arg("B") ); 125 m->addAction( i18n("Copy %1->Output",QString("B") ));
125 m->addAction( i18n("Copy %1->Output").arg("C") ); 126 m->addAction( i18n("Copy %1->Output",QString("C") ));
126 m->addAction( i18n("Swap %1<->Output").arg("A") ); 127 m->addAction( i18n("Swap %1<->Output",QString("A") ));
127 m->addAction( i18n("Swap %1<->Output").arg("B") ); 128 m->addAction( i18n("Swap %1<->Output",QString("B") ));
128 m->addAction( i18n("Swap %1<->Output").arg("C") ); 129 m->addAction( i18n("Swap %1<->Output",QString("C") ));
129 connect( m, SIGNAL(triggered(QAction*)), this, SLOT(slotSwapCopyNames(QAction*))); 130 connect( m, SIGNAL(triggered(QAction*)), this, SLOT(slotSwapCopyNames(QAction*)));
130 button->setMenu(m); 131 button->setMenu(m);
131 132
132 133
133 hl->addStretch(2); 134 hl->addStretch(2);
134 135
135 label = new QLabel( i18n("Output (optional):"), this ); 136 label = new QLabel( i18n("Output (optional):"), this );
136 m_pLineOut = new QComboBox(); 137 m_pLineOut = new QComboBox();
137 m_pLineOut->setEditable(true); 138 m_pLineOut->setEditable(true);
138 m_pLineOut->insertItems( 0, m_pOptions->m_recentOutputFiles ); 139 m_pLineOut->insertItems( 0, m_pOptions->m_recentOutputFiles );
139 m_pLineOut->setEditText( KURL(outputName).prettyURL() ); 140 m_pLineOut->setEditText( KUrl(outputName).prettyUrl() );
140 m_pLineOut->setMinimumWidth( 200 ); 141 m_pLineOut->setMinimumWidth( 200 );
141 button = new QPushButton( i18n("File..."), this ); 142 button = new QPushButton( i18n("File..."), this );
142 connect( button, SIGNAL(clicked()), this, SLOT( selectOutputName() ) ); 143 connect( button, SIGNAL(clicked()), this, SLOT( selectOutputName() ) );
143 button2 = new QPushButton( i18n("Dir..."), this ); 144 button2 = new QPushButton( i18n("Dir..."), this );
144 connect( button2, SIGNAL(clicked()), this, SLOT( selectOutputDir() ) ); 145 connect( button2, SIGNAL(clicked()), this, SLOT( selectOutputDir() ) );
227 { 228 {
228 QString current = pLine->currentText(); 229 QString current = pLine->currentText();
229 if (current.isEmpty() && i>3 ){ current = m_pLineC->currentText(); } 230 if (current.isEmpty() && i>3 ){ current = m_pLineC->currentText(); }
230 if (current.isEmpty() ){ current = m_pLineB->currentText(); } 231 if (current.isEmpty() ){ current = m_pLineB->currentText(); }
231 if (current.isEmpty() ){ current = m_pLineA->currentText(); } 232 if (current.isEmpty() ){ current = m_pLineA->currentText(); }
232 KURL newURL = bDir ? KFileDialog::getExistingURL( current, this) 233 KUrl newURL = bDir ? KFileDialog::getExistingDirectoryUrl( current, this)
233 : bSave ? KFileDialog::getSaveURL( current, 0, this) 234 : bSave ? KFileDialog::getSaveUrl( current, 0, this)
234 : KFileDialog::getOpenURL( current, 0, this); 235 : KFileDialog::getOpenUrl( current, 0, this);
235 if ( !newURL.isEmpty() ) 236 if ( !newURL.isEmpty() )
236 { 237 {
237 pLine->setEditText( newURL.url() ); 238 pLine->setEditText( newURL.url() );
238 } 239 }
239 // newURL won't be modified if nothing was selected. 240 // newURL won't be modified if nothing was selected.
283 { 284 {
284 int maxNofRecentFiles = 10; 285 int maxNofRecentFiles = 10;
285 fixCurrentText( m_pLineA ); 286 fixCurrentText( m_pLineA );
286 287
287 QString s = m_pLineA->currentText(); 288 QString s = m_pLineA->currentText();
288 s = KURL::fromPathOrURL(s).prettyURL(); 289 s = QUrl::fromLocalFile(s).toLocalFile();
289 QStringList* sl = &m_pOptions->m_recentAFiles; 290 QStringList* sl = &m_pOptions->m_recentAFiles;
290 // If an item exist, remove it from the list and reinsert it at the beginning. 291 // If an item exist, remove it from the list and reinsert it at the beginning.
291 sl->removeAll(s); 292 sl->removeAll(s);
292 if ( !s.isEmpty() ) sl->prepend( s ); 293 if ( !s.isEmpty() ) sl->prepend( s );
293 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() ); 294 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );
294 295
295 fixCurrentText( m_pLineB ); 296 fixCurrentText( m_pLineB );
296 s = m_pLineB->currentText(); 297 s = m_pLineB->currentText();
297 s = KURL::fromPathOrURL(s).prettyURL(); 298 s = QUrl::fromLocalFile(s).toLocalFile();
298 sl = &m_pOptions->m_recentBFiles; 299 sl = &m_pOptions->m_recentBFiles;
299 sl->removeAll(s); 300 sl->removeAll(s);
300 if ( !s.isEmpty() ) sl->prepend( s ); 301 if ( !s.isEmpty() ) sl->prepend( s );
301 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() ); 302 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );
302 303
303 fixCurrentText( m_pLineC ); 304 fixCurrentText( m_pLineC );
304 s = m_pLineC->currentText(); 305 s = m_pLineC->currentText();
305 s = KURL::fromPathOrURL(s).prettyURL(); 306 s = QUrl::fromLocalFile(s).toLocalFile();
306 sl = &m_pOptions->m_recentCFiles; 307 sl = &m_pOptions->m_recentCFiles;
307 sl->removeAll(s); 308 sl->removeAll(s);
308 if ( !s.isEmpty() ) sl->prepend( s ); 309 if ( !s.isEmpty() ) sl->prepend( s );
309 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() ); 310 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );
310 311
311 fixCurrentText( m_pLineOut ); 312 fixCurrentText( m_pLineOut );
312 s = m_pLineOut->currentText(); 313 s = m_pLineOut->currentText();
313 s = KURL::fromPathOrURL(s).prettyURL(); 314 s = QUrl::fromLocalFile(s).toLocalFile();
314 sl = &m_pOptions->m_recentOutputFiles; 315 sl = &m_pOptions->m_recentOutputFiles;
315 sl->removeAll(s); 316 sl->removeAll(s);
316 if ( !s.isEmpty() ) sl->prepend( s ); 317 if ( !s.isEmpty() ) sl->prepend( s );
317 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() ); 318 if (sl->count()>maxNofRecentFiles) sl->erase( sl->begin()+maxNofRecentFiles, sl->end() );
318 319
571 QStringList parenthesesGroups; 572 QStringList parenthesesGroups;
572 bool bSuccess = findParenthesesGroups( m_pHistoryEntryStartRegExpEdit->text(), parenthesesGroups ); 573 bool bSuccess = findParenthesesGroups( m_pHistoryEntryStartRegExpEdit->text(), parenthesesGroups );
573 if ( ! bSuccess ) 574 if ( ! bSuccess )
574 { 575 {
575 m_pHistoryEntryStartMatchResult->setText( i18n("Opening and closing parentheses don't match in regular expression.") ); 576 m_pHistoryEntryStartMatchResult->setText( i18n("Opening and closing parentheses don't match in regular expression.") );
576 m_pHistorySortKeyResult->setText( i18n("") ); 577 m_pHistorySortKeyResult->setText( "" );
577 return; 578 return;
578 } 579 }
579 QRegExp historyEntryStartRegExp( m_pHistoryEntryStartRegExpEdit->text() ); 580 QRegExp historyEntryStartRegExp( m_pHistoryEntryStartRegExpEdit->text() );
580 QString s = m_pHistoryEntryStartExampleEdit->text(); 581 QString s = m_pHistoryEntryStartExampleEdit->text();
581 582
586 m_pHistorySortKeyResult->setText(key); 587 m_pHistorySortKeyResult->setText(key);
587 } 588 }
588 else 589 else
589 { 590 {
590 m_pHistoryEntryStartMatchResult->setText( i18n("Match failed.") ); 591 m_pHistoryEntryStartMatchResult->setText( i18n("Match failed.") );
591 m_pHistorySortKeyResult->setText( i18n("") ); 592 m_pHistorySortKeyResult->setText( "" );
592 } 593 }
593 } 594 }
594 595
595 //#include "smalldialogs.moc" 596 //#include "smalldialogs.moc"