85 const TQString &_src,
const TQString &_dest,
94 : TQDialog ( parent,
"TDEIO::RenameDialog" , _modal )
96 d =
new RenameDlgPrivate( );
102#if !defined(TQ_WS_QWS) && !defined(TQ_WS_WIN)
104 KWin::setState( winId(), NET::StaysOnTop );
113 setCaption( _caption );
115 d->bCancel =
new KPushButton( KStdGuiItem::cancel(),
this );
116 connect(d->bCancel, TQ_SIGNAL(clicked()),
this, TQ_SLOT(
b0Pressed()));
118 if ( ! (_mode & M_NORENAME ) ) {
119 d->bRename =
new TQPushButton( i18n(
"&Rename" ),
this );
120 d->bRename->setEnabled(
false);
121 d->bSuggestNewName =
new TQPushButton( i18n(
"Suggest New &Name" ),
this );
122 connect(d->bSuggestNewName, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b8Pressed()));
123 connect(d->bRename, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b1Pressed()));
126 if ( ( _mode & M_MULTI ) && ( _mode & M_SKIP ) ) {
127 d->bSkip =
new TQPushButton( i18n(
"&Skip" ),
this );
128 connect(d->bSkip, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b2Pressed()));
130 d->bAutoSkip =
new TQPushButton( i18n(
"&Auto Skip" ),
this );
131 connect(d->bAutoSkip, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b3Pressed()));
134 if ( _mode & M_OVERWRITE ) {
135 d->bOverwrite =
new TQPushButton( i18n(
"&Overwrite" ),
this );
136 connect(d->bOverwrite, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b4Pressed()));
138 if ( _mode & M_MULTI ) {
139 d->bOverwriteAll =
new TQPushButton( i18n(
"O&verwrite All" ),
this );
140 connect(d->bOverwriteAll, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b5Pressed()));
144 if ( _mode & M_RESUME ) {
145 d->bResume =
new TQPushButton( i18n(
"&Resume" ),
this );
146 connect(d->bResume, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b6Pressed()));
148 if ( _mode & M_MULTI )
150 d->bResumeAll =
new TQPushButton( i18n(
"R&esume All" ),
this );
151 connect(d->bResumeAll, TQ_SIGNAL(clicked()),
this, TQ_SLOT(b7Pressed()));
155 TQVBoxLayout* pLayout =
new TQVBoxLayout(
this, KDialog::marginHint(),
156 KDialog::spacingHint() );
157 pLayout->addStrut( 360 );
160 if ( _mode & M_OVERWRITE_ITSELF ) {
161 TQLabel *lb =
new TQLabel( i18n(
"This action would overwrite '%1' with itself.\n"
162 "Please enter a new file name:" ).arg( KStringHandler::csqueeze( d->src.pathOrURL(),100 ) ),
this );
163 d->bRename->setText(i18n(
"C&ontinue"));
164 pLayout->addWidget( lb );
166 else if ( _mode & M_OVERWRITE ) {
178 if(!plugin_offers.isEmpty() ){
179 kdDebug(7024) <<
"Offers" << endl;
180 TDETrader::OfferList::ConstIterator it = plugin_offers.begin();
181 TDETrader::OfferList::ConstIterator end = plugin_offers.end();
182 for( ; it != end; ++it ){
183 TQString libName = (*it)->library();
184 if( libName.isEmpty() ){
185 kdDebug(7024) <<
"lib is empty" << endl;
188 KLibrary *lib = KLibLoader::self()->library(libName.local8Bit() );
192 KLibFactory *factory = lib->factory();
197 TQObject *obj = factory->create(
this, (*it)->name().latin1() );
207 if( plugin->
initialize( _mode, _src, _dest, d->mimeSrc,
208 d->mimeDest, sizeSrc, sizeDest,
210 mtimeSrc, mtimeDest ) ) {
212 pLayout->addWidget(plugin );
213 kdDebug(7024) <<
"RenameDlgPlugin" << endl;
224 TQGridLayout * gridLayout =
new TQGridLayout( 0L, 9, 2, KDialog::marginHint(),
225 KDialog::spacingHint() );
226 pLayout->addLayout(gridLayout);
227 gridLayout->setColStretch(0,0);
228 gridLayout->setColStretch(1,10);
231 if (mtimeDest < mtimeSrc)
232 sentence1 = i18n(
"An older item named '%1' already exists.");
233 else if (mtimeDest == mtimeSrc)
234 sentence1 = i18n(
"A similar file named '%1' already exists.");
236 sentence1 = i18n(
"A newer item named '%1' already exists.");
238 TQLabel * lb1 =
new KSqueezedTextLabel( sentence1.arg(d->dest.pathOrURL() ),
this );
239 gridLayout->addMultiCellWidget( lb1, 0, 0, 0, 1 );
241 lb1 =
new TQLabel(
this );
243 gridLayout->addMultiCellWidget( lb1, 1, 3, 0, 0 );
248 TQLabel * lb =
new TQLabel( i18n(
"size %1").arg(
TDEIO::convertSize(sizeDest) ),
this );
249 gridLayout->addWidget( lb, row, 1 );
253 if ( ctimeDest != (time_t)-1 )
255 TQDateTime dctime; dctime.setTime_t( ctimeDest );
256 TQLabel * lb =
new TQLabel( i18n(
"created on %1").arg( TDEGlobal::locale()->formatDateTime(dctime) ),
this );
257 gridLayout->addWidget( lb, row, 1 );
260 if ( mtimeDest != (time_t)-1 )
262 TQDateTime dmtime; dmtime.setTime_t( mtimeDest );
263 TQLabel * lb =
new TQLabel( i18n(
"modified on %1").arg( TDEGlobal::locale()->formatDateTime(dmtime) ),
this );
264 gridLayout->addWidget( lb, row, 1 );
268 if ( !d->src.isEmpty() )
271 gridLayout->addRowSpacing( 4, 20 );
273 TQLabel * lb2 =
new KSqueezedTextLabel( i18n(
"The source file is '%1'").arg(d->src.pathOrURL()),
this );
274 gridLayout->addMultiCellWidget( lb2, 5, 5, 0, 1 );
276 lb2 =
new TQLabel(
this );
278 gridLayout->addMultiCellWidget( lb2, 6, 8, 0, 0 );
284 TQLabel * lb =
new TQLabel( i18n(
"size %1").arg(
TDEIO::convertSize(sizeSrc) ),
this );
285 gridLayout->addWidget( lb, row, 1 );
288 if ( ctimeSrc != (time_t)-1 )
290 TQDateTime dctime; dctime.setTime_t( ctimeSrc );
291 TQLabel * lb =
new TQLabel( i18n(
"created on %1").arg( TDEGlobal::locale()->formatDateTime(dctime) ),
this );
292 gridLayout->addWidget( lb, row, 1 );
295 if ( mtimeSrc != (time_t)-1 )
297 TQDateTime dmtime; dmtime.setTime_t( mtimeSrc );
298 TQLabel * lb =
new TQLabel( i18n(
"modified on %1").arg( TDEGlobal::locale()->formatDateTime(dmtime) ),
this );
299 gridLayout->addWidget( lb, row, 1 );
310 if (mtimeDest < mtimeSrc)
311 sentence1 = i18n(
"An older item named '%1' already exists.");
312 else if (mtimeDest == mtimeSrc)
313 sentence1 = i18n(
"A similar file named '%1' already exists.");
315 sentence1 = i18n(
"A newer item named '%1' already exists.");
317 TQLabel *lb =
new KSqueezedTextLabel( sentence1.arg(d->dest.pathOrURL()),
this );
318 pLayout->addWidget(lb);
320 TQHBoxLayout* layout2 =
new TQHBoxLayout();
321 pLayout->addLayout( layout2 );
323 d->m_pLineEdit =
new TQLineEdit(
this );
324 layout2->addWidget( d->m_pLineEdit );
325 TQString fileName = d->dest.fileName();
327 if ( d->bRename || d->bOverwrite )
328 connect(d->m_pLineEdit, TQ_SIGNAL(textChanged(
const TQString &)),
329 TQ_SLOT(enableRenameButton(
const TQString &)));
330 if ( d->bSuggestNewName )
332 layout2->addWidget( d->bSuggestNewName );
333 setTabOrder( d->m_pLineEdit, d->bSuggestNewName );
336 KSeparator* separator =
new KSeparator(
this );
337 pLayout->addWidget( separator );
339 TQHBoxLayout* layout =
new TQHBoxLayout();
340 pLayout->addLayout( layout );
342 layout->addStretch(1);
346 layout->addWidget( d->bRename );
347 setTabOrder( d->bRename, d->bCancel );
351 layout->addWidget( d->bSkip );
352 setTabOrder( d->bSkip, d->bCancel );
356 layout->addWidget( d->bAutoSkip );
357 setTabOrder( d->bAutoSkip, d->bCancel );
361 layout->addWidget( d->bOverwrite );
362 setTabOrder( d->bOverwrite, d->bCancel );
364 if ( d->bOverwriteAll )
366 layout->addWidget( d->bOverwriteAll );
367 setTabOrder( d->bOverwriteAll, d->bCancel );
371 layout->addWidget( d->bResume );
372 setTabOrder( d->bResume, d->bCancel );
376 layout->addWidget( d->bResumeAll );
377 setTabOrder( d->bResumeAll, d->bCancel );
380 d->bCancel->setDefault(
true );
381 layout->addWidget( d->bCancel );
383 resize( sizeHint() );
385 d->m_pLineEdit->setFocus();