• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KIO

renamedialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00003                   1999 - 2008 David Faure <faure@kde.org>
00004                   2001, 2006 Holger Freyther <freyther@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "kio/renamedialog.h"
00023 #include <stdio.h>
00024 #include <assert.h>
00025 
00026 #include <QtCore/QDate>
00027 #include <QtCore/QFileInfo>
00028 #include <QtGui/QCheckBox>
00029 #include <QtGui/QLabel>
00030 #include <QtGui/QLayout>
00031 #include <QtGui/QPixmap>
00032 #include <QtGui/QScrollArea>
00033 #include <QtCore/QDir>
00034 
00035 #include <klineedit.h>
00036 #include <kmessagebox.h>
00037 #include <kpushbutton.h>
00038 #include <kio/global.h>
00039 #include <kio/udsentry.h>
00040 #include <kdialog.h>
00041 #include <klocale.h>
00042 #include <kglobal.h>
00043 #include <kdebug.h>
00044 #include <kurl.h>
00045 #include <kfileitem.h>
00046 #include <kmimetype.h>
00047 #include <kseparator.h>
00048 #include <kstringhandler.h>
00049 #include <kstandardguiitem.h>
00050 #include <kguiitem.h>
00051 #include <ksqueezedtextlabel.h>
00052 #include <kfilemetadatawidget.h>
00053 #include <previewjob.h>
00054 
00055 using namespace KIO;
00056 
00058 class RenameDialog::RenameDialogPrivate
00059 {
00060 public:
00061     RenameDialogPrivate() {
00062         bCancel = 0;
00063         bRename = bSkip = bOverwrite = 0;
00064         bResume = bSuggestNewName = 0;
00065         bApplyAll = 0;
00066         m_pLineEdit = 0;
00067         m_srcPendingPreview = false;
00068         m_destPendingPreview = false;
00069         m_srcPreview = 0;
00070         m_destPreview = 0;
00071     }
00072 
00073     void setRenameBoxText(const QString& fileName) {
00074         // sets the text in file name line edit box, selecting the filename (but not the extension if there is one).
00075         const QString extension = KMimeType::extractKnownExtension(fileName);
00076         m_pLineEdit->setText(fileName);
00077 
00078         if (!extension.isEmpty()) {
00079             const int selectionLength = fileName.length() - extension.length() - 1;
00080             m_pLineEdit->setSelection(0, selectionLength);
00081         } else {
00082             m_pLineEdit->selectAll();
00083         }
00084     }
00085 
00086     KPushButton *bCancel;
00087     QPushButton *bRename;
00088     QPushButton *bSkip;
00089     QPushButton *bOverwrite;
00090     QPushButton *bResume;
00091     QPushButton *bSuggestNewName;
00092     QCheckBox *bApplyAll;
00093     KLineEdit* m_pLineEdit;
00094     KUrl src;
00095     KUrl dest;
00096     bool m_srcPendingPreview;
00097     bool m_destPendingPreview;
00098     QLabel* m_srcPreview;
00099     QLabel* m_destPreview;
00100 };
00101 
00102 RenameDialog::RenameDialog(QWidget *parent, const QString & _caption,
00103                            const KUrl &_src, const KUrl &_dest,
00104                            RenameDialog_Mode _mode,
00105                            KIO::filesize_t sizeSrc,
00106                            KIO::filesize_t sizeDest,
00107                            time_t ctimeSrc,
00108                            time_t ctimeDest,
00109                            time_t mtimeSrc,
00110                            time_t mtimeDest)
00111         : QDialog(parent), d(new RenameDialogPrivate)
00112 {
00113     setObjectName("KIO::RenameDialog");
00114 
00115     d->src = _src;
00116     d->dest = _dest;
00117 
00118     setWindowTitle(_caption);
00119 
00120     d->bCancel = new KPushButton(KStandardGuiItem::cancel(), this);
00121     connect(d->bCancel, SIGNAL(clicked()), this, SLOT(cancelPressed()));
00122 
00123     if (_mode & M_MULTI) {
00124         d->bApplyAll = new QCheckBox(i18n("Appl&y to All"), this);
00125         d->bApplyAll->setToolTip((_mode & M_ISDIR) ? i18n("When this is checked the button pressed will be applied to all subsequent folder conflicts for the remainder of the current job.\nUnless you press Skip you will still be prompted in case of a conflict with an existing file in the directory.")
00126                                  : i18n("When this is checked the button pressed will be applied to all subsequent conflicts for the remainder of the current job."));
00127         connect(d->bApplyAll, SIGNAL(clicked()), this, SLOT(applyAllPressed()));
00128     }
00129 
00130     if (!(_mode & M_NORENAME)) {
00131         d->bRename = new QPushButton(i18n("&Rename"), this);
00132         d->bRename->setEnabled(false);
00133         d->bSuggestNewName = new QPushButton(i18n("Suggest New &Name"), this);
00134         connect(d->bSuggestNewName, SIGNAL(clicked()), this, SLOT(suggestNewNamePressed()));
00135         connect(d->bRename, SIGNAL(clicked()), this, SLOT(renamePressed()));
00136     }
00137 
00138     if ((_mode & M_MULTI) && (_mode & M_SKIP)) {
00139         d->bSkip = new QPushButton(i18n("&Skip"), this);
00140         d->bSkip->setToolTip((_mode & M_ISDIR) ? i18n("Do not copy or move this folder, skip to the next item instead")
00141                              : i18n("Do not copy or move this file, skip to the next item instead"));
00142         connect(d->bSkip, SIGNAL(clicked()), this, SLOT(skipPressed()));
00143     }
00144 
00145     if (_mode & M_OVERWRITE) {
00146         const QString text = (_mode & M_ISDIR) ? i18nc("Write files into an existing folder", "&Write Into") : i18n("&Overwrite");
00147         d->bOverwrite = new QPushButton(text, this);
00148         d->bOverwrite->setToolTip(i18n("Files and folders will be copied into the existing directory, alongside its existing contents.\nYou will be prompted again in case of a conflict with an existing file in the directory."));
00149         connect(d->bOverwrite, SIGNAL(clicked()), this, SLOT(overwritePressed()));
00150     }
00151 
00152     if (_mode & M_RESUME) {
00153         d->bResume = new QPushButton(i18n("&Resume"), this);
00154         connect(d->bResume, SIGNAL(clicked()), this, SLOT(resumePressed()));
00155     }
00156 
00157     QVBoxLayout* pLayout = new QVBoxLayout(this);
00158     pLayout->addStrut(400);     // makes dlg at least that wide
00159 
00160     // User tries to overwrite a file with itself ?
00161     if (_mode & M_OVERWRITE_ITSELF) {
00162         QLabel *lb = new QLabel(i18n("This action would overwrite '%1' with itself.\n"
00163                                      "Please enter a new file name:",
00164                                      KStringHandler::csqueeze(d->src.pathOrUrl(), 100)), this);
00165 
00166         d->bRename->setText(i18n("C&ontinue"));
00167         pLayout->addWidget(lb);
00168     } else if (_mode & M_OVERWRITE) {
00169         KFileItem srcItem;
00170         KFileItem destItem;
00171 
00172         if (d->src.isLocalFile()) {
00173             srcItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, d->src);
00174         } else {
00175             UDSEntry srcUds;
00176 
00177             srcUds.insert(UDSEntry::UDS_NAME, d->src.fileName());
00178             srcUds.insert(UDSEntry::UDS_MODIFICATION_TIME, mtimeSrc);
00179             srcUds.insert(UDSEntry::UDS_CREATION_TIME, ctimeSrc);
00180             srcUds.insert(UDSEntry::UDS_SIZE, sizeSrc);
00181 
00182             srcItem = KFileItem(srcUds, d->src);
00183         }
00184 
00185         if (d->dest.isLocalFile()) {
00186             destItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, d->dest);
00187         } else {
00188             UDSEntry destUds;
00189 
00190             destUds.insert(UDSEntry::UDS_NAME, d->dest.fileName());
00191             destUds.insert(UDSEntry::UDS_MODIFICATION_TIME, mtimeDest);
00192             destUds.insert(UDSEntry::UDS_CREATION_TIME, ctimeDest);
00193             destUds.insert(UDSEntry::UDS_SIZE, sizeDest);
00194 
00195             destItem = KFileItem(destUds, d->dest);
00196         }
00197 
00198         d->m_srcPreview = createLabel(parent, QString(), false);
00199         d->m_destPreview = createLabel(parent, QString(), false);
00200 
00201         d->m_srcPreview->setMinimumHeight(KIconLoader::SizeEnormous);
00202         d->m_destPreview->setMinimumHeight(KIconLoader::SizeEnormous);
00203 
00204         d->m_srcPendingPreview = true;
00205         d->m_destPendingPreview = true;
00206 
00207         KIO::PreviewJob* srcJob = KIO::filePreview(KFileItemList() << srcItem,
00208                                   d->m_srcPreview->width(),
00209                                   d->m_srcPreview->height(),
00210                                   0,
00211                                   0,
00212                                   false /*don't scale*/);
00213 
00214         KIO::PreviewJob* destJob = KIO::filePreview(KFileItemList() << destItem,
00215                                    d->m_destPreview->width(),
00216                                    d->m_destPreview->height(),
00217                                    0,
00218                                    0,
00219                                    false /*don't scale*/);
00220 
00221         connect(srcJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
00222                 this, SLOT(showSrcPreview(const KFileItem&, const QPixmap&)));
00223         connect(destJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
00224                 this, SLOT(showDestPreview(const KFileItem&, const QPixmap&)));
00225         connect(srcJob, SIGNAL(failed(const KFileItem&)),
00226                 this, SLOT(showSrcIcon(const KFileItem&)));
00227         connect(destJob, SIGNAL(failed(const KFileItem&)),
00228                 this, SLOT(showDestIcon(const KFileItem&)));
00229 
00230         // widget
00231         QScrollArea* srcWidget = createContainerLayout(parent, srcItem, d->m_srcPreview);
00232         QScrollArea* destWidget = createContainerLayout(parent, destItem, d->m_destPreview);
00233 
00234         // create layout
00235         QGridLayout* gridLayout = new QGridLayout();
00236         pLayout->addLayout(gridLayout);
00237 
00238         QLabel* titleLabel = new QLabel(i18n("This action will overwrite the destination."), this);
00239 
00240         QLabel* srcTitle = createLabel(parent, i18n("Source"), true);
00241         QLabel* destTitle = createLabel(parent, i18n("Destination"), true);
00242 
00243         QLabel* srcInfo = createSqueezedLabel(parent, d->src.pathOrUrl());
00244         QLabel* destInfo = createSqueezedLabel(parent, d->dest.pathOrUrl());
00245 
00246         if (mtimeDest > mtimeSrc) {
00247             QLabel* warningLabel = new QLabel(i18n("Warning, the destination is newer."), this);
00248 
00249             gridLayout->addWidget(titleLabel, 0, 0, 1, 2);    // takes the complete first line
00250             gridLayout->addWidget(warningLabel, 1, 0, 1, 2);
00251             gridLayout->setRowMinimumHeight(2, 15);    // spacer
00252 
00253             gridLayout->addWidget(srcTitle, 3, 0);
00254             gridLayout->addWidget(srcInfo, 4, 0);
00255             gridLayout->addWidget(srcWidget, 5, 0);
00256 
00257             gridLayout->addWidget(destTitle, 3, 1);
00258             gridLayout->addWidget(destInfo, 4, 1);
00259             gridLayout->addWidget(destWidget, 5, 1);
00260         } else {
00261             gridLayout->addWidget(titleLabel, 0, 0, 1, 2);
00262             gridLayout->setRowMinimumHeight(1, 15);
00263 
00264             gridLayout->addWidget(srcTitle, 2, 0);
00265             gridLayout->addWidget(srcInfo, 3, 0);
00266             gridLayout->addWidget(srcWidget, 4, 0);
00267 
00268             gridLayout->addWidget(destTitle, 2, 1);
00269             gridLayout->addWidget(destInfo, 3, 1);
00270             gridLayout->addWidget(destWidget, 4, 1);
00271         }
00272     } else {
00273         // This is the case where we don't want to allow overwriting, the existing
00274         // file must be preserved (e.g. when renaming).
00275         QString sentence1;
00276 
00277         if (mtimeDest < mtimeSrc)
00278             sentence1 = i18n("An older item named '%1' already exists.", d->dest.pathOrUrl());
00279         else if (mtimeDest == mtimeSrc)
00280             sentence1 = i18n("A similar file named '%1' already exists.", d->dest.pathOrUrl());
00281         else
00282             sentence1 = i18n("A newer item named '%1' already exists.", d->dest.pathOrUrl());
00283 
00284         QLabel *lb = new KSqueezedTextLabel(sentence1, this);
00285         pLayout->addWidget(lb);
00286     }
00287 
00288     if ((_mode != M_OVERWRITE_ITSELF) && (_mode != M_NORENAME)) {
00289         if (_mode == M_OVERWRITE) {
00290             pLayout->addSpacing(15);    // spacer
00291         }
00292 
00293         QLabel *lb2 = new QLabel(i18n("Rename:"), this);
00294         pLayout->addWidget(lb2);
00295     }
00296 
00297     QHBoxLayout* layout2 = new QHBoxLayout();
00298     pLayout->addLayout(layout2);
00299 
00300     d->m_pLineEdit = new KLineEdit(this);
00301     layout2->addWidget(d->m_pLineEdit);
00302 
00303     if (d->bRename) {
00304         const QString fileName = d->dest.fileName();
00305         d->setRenameBoxText(KIO::decodeFileName(fileName));
00306 
00307         connect(d->m_pLineEdit, SIGNAL(textChanged(const QString &)),
00308                 SLOT(enableRenameButton(const QString &)));
00309 
00310         d->m_pLineEdit->setFocus();
00311     } else {
00312         d->m_pLineEdit->hide();
00313     }
00314 
00315     if (d->bSuggestNewName) {
00316         layout2->addWidget(d->bSuggestNewName);
00317         setTabOrder(d->m_pLineEdit, d->bSuggestNewName);
00318     }
00319 
00320     KSeparator* separator = new KSeparator(this);
00321     pLayout->addWidget(separator);
00322 
00323     QHBoxLayout* layout = new QHBoxLayout();
00324     pLayout->addLayout(layout);
00325 
00326     layout->addStretch(1);
00327 
00328     if (d->bApplyAll) {
00329         layout->addWidget(d->bApplyAll);
00330         setTabOrder(d->bApplyAll, d->bCancel);
00331     }
00332 
00333     if (d->bRename) {
00334         layout->addWidget(d->bRename);
00335         setTabOrder(d->bRename, d->bCancel);
00336     }
00337 
00338     if (d->bSkip) {
00339         layout->addWidget(d->bSkip);
00340         setTabOrder(d->bSkip, d->bCancel);
00341     }
00342 
00343     if (d->bOverwrite) {
00344         layout->addWidget(d->bOverwrite);
00345         setTabOrder(d->bOverwrite, d->bCancel);
00346     }
00347 
00348     if (d->bResume) {
00349         layout->addWidget(d->bResume);
00350         setTabOrder(d->bResume, d->bCancel);
00351     }
00352 
00353     d->bCancel->setDefault(true);
00354     layout->addWidget(d->bCancel);
00355 
00356     resize(sizeHint());
00357 }
00358 
00359 RenameDialog::~RenameDialog()
00360 {
00361     delete d;
00362     // no need to delete Pushbuttons,... qt will do this
00363 }
00364 
00365 void RenameDialog::enableRenameButton(const QString &newDest)
00366 {
00367     if (newDest != KIO::decodeFileName(d->dest.fileName()) && !newDest.isEmpty()) {
00368         d->bRename->setEnabled(true);
00369         d->bRename->setDefault(true);
00370 
00371         if (d->bOverwrite) {
00372             d->bOverwrite->setEnabled(false);   // prevent confusion (#83114)
00373         }
00374     } else {
00375         d->bRename->setEnabled(false);
00376 
00377         if (d->bOverwrite) {
00378             d->bOverwrite->setEnabled(true);
00379         }
00380     }
00381 }
00382 
00383 KUrl RenameDialog::newDestUrl()
00384 {
00385     KUrl newDest(d->dest);
00386     QString fileName = d->m_pLineEdit->text();
00387 
00388     newDest.setFileName(KIO::encodeFileName(fileName));
00389 
00390     return newDest;
00391 }
00392 
00393 KUrl RenameDialog::autoDestUrl() const
00394 {
00395     KUrl newDest(d->dest);
00396     KUrl destDirectory(d->dest);
00397 
00398     destDirectory.setPath(destDirectory.directory());
00399     newDest.setFileName(suggestName(destDirectory, d->dest.fileName()));
00400 
00401     return newDest;
00402 }
00403 
00404 void RenameDialog::cancelPressed()
00405 {
00406     done(R_CANCEL);
00407 }
00408 
00409 // Rename
00410 void RenameDialog::renamePressed()
00411 {
00412     if (d->m_pLineEdit->text().isEmpty()) {
00413         return;
00414     }
00415 
00416     if (d->bApplyAll  && d->bApplyAll->isChecked()) {
00417         done(R_AUTO_RENAME);
00418     } else {
00419         KUrl u = newDestUrl();
00420 
00421         if (!u.isValid()) {
00422             KMessageBox::error(this, i18n("Malformed URL\n%1" ,  u.url()));
00423             return;
00424         }
00425 
00426         done(R_RENAME);
00427     }
00428 }
00429 
00430 QString RenameDialog::suggestName(const KUrl& baseURL, const QString& oldName)
00431 {
00432     QString dotSuffix, suggestedName;
00433     QString basename = oldName;
00434     const QChar spacer(' ');
00435 
00436     int index = basename.indexOf('.');
00437 
00438     if (index != -1) {
00439         dotSuffix = basename.mid(index);
00440         basename.truncate(index);
00441     }
00442 
00443     int pos = basename.lastIndexOf(spacer);
00444 
00445     if (pos != -1) {
00446         QString tmp = basename.mid(pos + 1);
00447         bool ok;
00448         int number = tmp.toInt(&ok);
00449 
00450         if (!ok) {  // ok there is no number
00451             suggestedName = basename + spacer + '1' + dotSuffix;
00452         } else {
00453             // yes there's already a number behind the spacer so increment it by one
00454             basename.replace(pos + 1, tmp.length(), QString::number(number + 1));
00455             suggestedName = basename + dotSuffix;
00456         }
00457     } else // no spacer yet
00458         suggestedName = basename + spacer + "1" + dotSuffix ;
00459 
00460     // Check if suggested name already exists
00461     bool exists = false;
00462     // TODO: network transparency. However, using NetAccess from a modal dialog
00463     // could be a problem, no? (given that it uses a modal widget itself....)
00464     if (baseURL.isLocalFile())
00465         exists = QFileInfo(baseURL.toLocalFile(KUrl::AddTrailingSlash) + suggestedName).exists();
00466 
00467     if (!exists)
00468         return suggestedName;
00469     else // already exists -> recurse
00470         return suggestName(baseURL, suggestedName);
00471 }
00472 
00473 // Propose button clicked
00474 void RenameDialog::suggestNewNamePressed()
00475 {
00476     /* no name to play with */
00477     if (d->m_pLineEdit->text().isEmpty())
00478         return;
00479 
00480     KUrl destDirectory(d->dest);
00481 
00482     destDirectory.setPath(destDirectory.directory());
00483     d->setRenameBoxText(suggestName(destDirectory, d->m_pLineEdit->text()));
00484 
00485     return;
00486 }
00487 
00488 void RenameDialog::skipPressed()
00489 {
00490     if (d->bApplyAll  && d->bApplyAll->isChecked()) {
00491         done(R_AUTO_SKIP);
00492     } else {
00493         done(R_SKIP);
00494     }
00495 }
00496 
00497 void RenameDialog::autoSkipPressed()
00498 {
00499     done(R_AUTO_SKIP);
00500 }
00501 
00502 void RenameDialog::overwritePressed()
00503 {
00504     if (d->bApplyAll  && d->bApplyAll->isChecked()) {
00505         done(R_OVERWRITE_ALL);
00506     } else {
00507         done(R_OVERWRITE);
00508     }
00509 }
00510 
00511 void RenameDialog::overwriteAllPressed()
00512 {
00513     done(R_OVERWRITE_ALL);
00514 }
00515 
00516 void RenameDialog::resumePressed()
00517 {
00518     if (d->bApplyAll  && d->bApplyAll->isChecked()) {
00519         done(R_RESUME_ALL);
00520     } else {
00521         done(R_RESUME);
00522     }
00523 }
00524 
00525 void RenameDialog::resumeAllPressed()
00526 {
00527     done(R_RESUME_ALL);
00528 }
00529 
00530 void RenameDialog::applyAllPressed()
00531 {
00532     if (d->bApplyAll  && d->bApplyAll->isChecked()) {
00533         d->m_pLineEdit->setText(KIO::decodeFileName(d->dest.fileName()));
00534         d->m_pLineEdit->setEnabled(false);
00535 
00536         if (d->bRename) {
00537             d->bRename->setEnabled(true);
00538         }
00539 
00540         if (d->bSuggestNewName) {
00541             d->bSuggestNewName->setEnabled(false);
00542         }
00543     } else {
00544         d->m_pLineEdit->setEnabled(true);
00545 
00546         if (d->bRename) {
00547             d->bRename->setEnabled(false);
00548         }
00549 
00550         if (d->bSuggestNewName) {
00551             d->bSuggestNewName->setEnabled(true);
00552         }
00553     }
00554 }
00555 
00556 void RenameDialog::showSrcIcon(const KFileItem& fileitem)
00557 {
00558     // The preview job failed, show a standard file icon.
00559     d->m_srcPendingPreview = false;
00560     d->m_srcPreview->setPixmap(fileitem.pixmap(d->m_srcPreview->height()));
00561 }
00562 
00563 void RenameDialog::showDestIcon(const KFileItem& fileitem)
00564 {
00565     // The preview job failed, show a standard file icon.
00566     d->m_destPendingPreview = false;
00567     d->m_destPreview->setPixmap(fileitem.pixmap(d->m_srcPreview->height()));
00568 }
00569 
00570 void RenameDialog::showSrcPreview(const KFileItem& fileitem, const QPixmap& pixmap)
00571 {
00572     Q_UNUSED(fileitem);
00573 
00574     if (d->m_srcPendingPreview) {
00575         d->m_srcPreview->setPixmap(pixmap);
00576         d->m_srcPendingPreview = false;
00577     }
00578 }
00579 
00580 void RenameDialog::showDestPreview(const KFileItem& fileitem, const QPixmap& pixmap)
00581 {
00582     Q_UNUSED(fileitem);
00583 
00584     if (d->m_destPendingPreview) {
00585         d->m_destPreview->setPixmap(pixmap);
00586         d->m_destPendingPreview = false;
00587     }
00588 }
00589 
00590 QScrollArea* RenameDialog::createContainerLayout(QWidget* parent, const KFileItem& item, QLabel* preview)
00591 {
00592     KFileItemList itemList;
00593     itemList << item;
00594 
00595     // widget
00596     KFileMetaDataWidget* metaWidget =  new KFileMetaDataWidget(this);
00597 
00598     metaWidget->setReadOnly(true);
00599     metaWidget->setItems(itemList);
00600 
00601     // Encapsulate the MetaDataWidgets inside a container with stretch at the bottom.
00602     // This prevents that the meta data widgets get vertically stretched
00603     // in the case where the height of m_metaDataArea > m_metaDataWidget.
00604 
00605     QWidget* widgetContainer = new QWidget(parent);
00606     QVBoxLayout* containerLayout = new QVBoxLayout(widgetContainer);
00607 
00608     containerLayout->setContentsMargins(0, 0, 0, 0);
00609     containerLayout->setSpacing(0);
00610     containerLayout->addWidget(preview);
00611     containerLayout->addWidget(metaWidget);
00612     containerLayout->addStretch(1);
00613 
00614     QScrollArea* metaDataArea = new QScrollArea(parent);
00615 
00616     metaDataArea->setWidget(widgetContainer);
00617     metaDataArea->setWidgetResizable(true);
00618     metaDataArea->setFrameShape(QFrame::NoFrame);
00619 
00620     return metaDataArea;
00621 }
00622 
00623 QLabel* RenameDialog::createLabel(QWidget* parent, const QString& text, bool containerTitle)
00624 {
00625     QLabel* label = new QLabel(parent);
00626 
00627     if (containerTitle) {
00628         QFont font = label->font();
00629         font.setBold(true);
00630         label->setFont(font);
00631     }
00632 
00633     label->setAlignment(Qt::AlignHCenter);
00634     label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
00635     label->setText(text);
00636 
00637     return label;
00638 }
00639 
00640 KSqueezedTextLabel* RenameDialog::createSqueezedLabel(QWidget* parent, const QString& text)
00641 {
00642     KSqueezedTextLabel* label = new KSqueezedTextLabel(text, parent);
00643 
00644     label->setAlignment(Qt::AlignHCenter);
00645     label->setFixedWidth(200);
00646 
00647     return label;
00648 }
00649 
00650 #include "renamedialog.moc"

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal