krenameimpl.cpp (krename-4.0.9) | : | krenameimpl.cpp (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
/*************************************************************************** | /*************************************************************************** | |||
* * | * * | |||
* This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | |||
* it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | |||
* the Free Software Foundation; either version 2 of the License, or * | * the Free Software Foundation; either version 2 of the License, or * | |||
* (at your option) any later version. * | * (at your option) any later version. * | |||
* * | * * | |||
***************************************************************************/ | ***************************************************************************/ | |||
#include "krenameimpl.h" | #include "krenameimpl.h" | |||
#include "krenameimpl.moc" | ||||
#include "filedialogextwidget.h" | #include "filedialogextwidget.h" | |||
#include "krenamemodel.h" | #include "krenamemodel.h" | |||
#include "krenametest.h" | #include "krenametest.h" | |||
#include "krenamewindow.h" | #include "krenamewindow.h" | |||
#include "krenamefile.h" | ||||
#include "numberdialog.h" | #include "numberdialog.h" | |||
#include "insertpartfilenamedlg.h" | #include "insertpartfilenamedlg.h" | |||
#include "plugin.h" | #include "plugin.h" | |||
#include "pluginloader.h" | #include "pluginloader.h" | |||
#include "progressdialog.h" | #include "progressdialog.h" | |||
#include "replacedialog.h" | #include "replacedialog.h" | |||
#include "threadedlister.h" | #include "threadedlister.h" | |||
#include "tokenhelpdialog.h" | #include "tokenhelpdialog.h" | |||
#include "modeltest.h" | #include "modeltest.h" | |||
#include <kaction.h> | ||||
#include <kapplication.h> | ||||
#include <kcmdlineargs.h> | ||||
#include <kconfig.h> | #include <kconfig.h> | |||
#include <kiconloader.h> | #include <kiconloader.h> | |||
#include <kfiledialog.h> | #include <KFileWidget> | |||
#include <kmenu.h> | ||||
#include <kmenubar.h> | ||||
#include <kmessagebox.h> | #include <kmessagebox.h> | |||
#include <kstandardaction.h> | #include <kstandardaction.h> | |||
#include <KJobWidgets> | ||||
#include <KIO/MkdirJob> | ||||
#include <KIO/StatJob> | ||||
#include <kio/netaccess.h> | #include <KHelpMenu> | |||
#include <QStringListModel> | ||||
#include <QTimer> | #include <QTimer> | |||
#include <QCommandLineParser> | ||||
KRenameImpl::KRenameImpl( KRenameWindow* window, const KRenameFile::List & list | #include <QDebug> | |||
) | #include <QMenuBar> | |||
: QObject( (QObject*)window ), m_window( window ), | #include <QPointer> | |||
m_lastSplitMode( eSplitMode_LastDot ), m_lastDot( 0 ), | ||||
m_runningThreadedListersCount( 0 ) | KRenameImpl::KRenameImpl(KRenameWindow *window, const KRenameFile::List &list, Q | |||
CommandLineParser *commandLine) | ||||
: QObject((QObject *)window), m_window(window), | ||||
m_lastSplitMode(eSplitMode_LastDot), m_lastDot(0), | ||||
m_runningThreadedListersCount(0) | ||||
{ | { | |||
setupActions(); | ||||
setupSlots(); | setupSlots(); | |||
m_model = new KRenameModel( &m_vector ); | m_model = new KRenameModel(&m_vector); | |||
m_window->setModel( m_model ); | m_window->setModel(m_model); | |||
connect( m_model, SIGNAL(filesDropped()), SLOT(slotUpdateCount())); | connect(m_model, &KRenameModel::filesDropped, | |||
this, &KRenameImpl::slotUpdateCount); | ||||
m_previewModel = new KRenamePreviewModel( &m_vector ); | m_previewModel = new KRenamePreviewModel(&m_vector); | |||
m_window->setPreviewModel( m_previewModel ); | m_window->setPreviewModel(m_previewModel); | |||
m_renamer.setFiles( &m_vector ); | m_renamer.setFiles(&m_vector); | |||
m_model->setRenamer( &m_renamer ); | m_model->setRenamer(&m_renamer); | |||
m_model->addFiles( list ); | m_model->addFiles(list); | |||
m_pluginLoader = PluginLoader::Instance(); | m_pluginLoader = PluginLoader::Instance(); | |||
m_pluginLoader->registerForUpdates( this ); | m_pluginLoader->registerForUpdates(this); | |||
loadConfig(); | loadConfig(); | |||
parseCmdLineOptions(); | if (commandLine) { | |||
parseCmdLineOptions(commandLine); | ||||
} | ||||
slotUpdateCount(); | slotUpdateCount(); | |||
connect( kapp, SIGNAL( aboutToQuit() ), this, SLOT( saveConfig() ) ); | connect(qApp, &QApplication::aboutToQuit, this, &KRenameImpl::saveConfig); | |||
} | } | |||
KRenameImpl::~KRenameImpl() | KRenameImpl::~KRenameImpl() | |||
{ | { | |||
m_pluginLoader->deregisterForUpdates( this ); | m_pluginLoader->deregisterForUpdates(this); | |||
delete m_model; | delete m_model; | |||
} | } | |||
QWidget* KRenameImpl::launch( const QRect & rect, const KRenameFile::List & list , bool loadprofile ) | QWidget *KRenameImpl::launch(const QRect &rect, const KRenameFile::List &list, Q CommandLineParser *commandLine) | |||
{ | { | |||
KSharedConfigPtr config = KGlobal::config(); | KSharedConfigPtr config = KSharedConfig::openConfig(); | |||
KConfigGroup groupGui = config->group( QString("GUISettings") ); | KConfigGroup groupGui = config->group(QString("GUISettings")); | |||
bool firststart = groupGui.readEntry( "firststart4", QVariant(true) ).toBoo | bool firststart = groupGui.readEntry("firststart4", QVariant(true)).toBool( | |||
l(); | ); | |||
if( firststart ) | if (firststart) { | |||
{ | ||||
// WELCOME TO KRENAME | // WELCOME TO KRENAME | |||
} | } | |||
KRenameWindow* w = new KRenameWindow( NULL ); | KRenameWindow *w = new KRenameWindow(nullptr); | |||
//KRenameImpl* impl = new KRenameImpl( w, list ); | //KRenameImpl* impl = new KRenameImpl( w, list ); | |||
new KRenameImpl( w, list ); | new KRenameImpl(w, list, commandLine); | |||
// Windows shows KRename otherwise outside of the visible | // Windows shows KRename otherwise outside of the visible | |||
// screen area | // screen area | |||
if( !rect.isNull() ) | if (!rect.isNull()) { | |||
w->setGeometry( rect ); | w->setGeometry(rect); | |||
} | ||||
/* | /* | |||
// it is time to load a default profile now (if the user has specified one) | // it is time to load a default profile now (if the user has specified one) | |||
if( loadprofile && !k->hasCommandlineProfile() && ProfileManager::hasDefault Profile() ) | if( loadprofile && !k->hasCommandlineProfile() && ProfileManager::hasDefault Profile() ) | |||
ProfileManager::loadDefaultProfile( k ); | ProfileManager::loadDefaultProfile( k ); | |||
else if ( !k->hasCommandlineProfile() ) | else if ( !k->hasCommandlineProfile() ) | |||
w->show(); | w->show(); | |||
*/ | */ | |||
w->show(); | w->show(); | |||
return w; | return w; | |||
} | } | |||
void KRenameImpl::setupActions() | ||||
{ | ||||
// Disabled profiles as they are not implemented right now | ||||
//KMenu* mnuExtra = new KMenu( i18n("E&xtras"), m_window ); | ||||
KMenu* mnuHelp = m_window->helpMenu( QString::null, true ); | ||||
//KAction* actProfiles = new KAction( i18n("&Profiles..."), m_window ); | ||||
//m_window->menuBar()->addMenu( mnuExtra ); | ||||
m_window->menuBar()->addMenu( mnuHelp ); | ||||
//mnuExtra->addAction( actProfiles ); | ||||
//connect(actProfiles, SIGNAL(triggered(bool)), SLOT(slotManageProfiles())); | ||||
} | ||||
void KRenameImpl::setupSlots() | void KRenameImpl::setupSlots() | |||
{ | { | |||
connect( m_window, SIGNAL(addFiles()), SLOT(slotAddFiles())); | connect(m_window, &KRenameWindow::addFiles, | |||
connect( m_window, SIGNAL(removeFiles()), SLOT(slotRemoveFiles())); | this, &KRenameImpl::slotAddFiles); | |||
connect( m_window, SIGNAL(removeAllFiles()), SLOT(slotRemoveAllFiles())); | connect(m_window, &KRenameWindow::removeFiles, | |||
this, &KRenameImpl::slotRemoveFiles); | ||||
connect( m_window, SIGNAL(updatePreview()), SLOT(slotUpdatePreview())); | connect(m_window, &KRenameWindow::removeAllFiles, | |||
connect( m_window, SIGNAL(updateCount()), SLOT(slotUpdateCount())); | this, &KRenameImpl::slotRemoveAllFiles); | |||
connect( m_window, SIGNAL(accepted()), SLOT(slotStart())); | connect(m_window, &KRenameWindow::updatePreview, | |||
this, &KRenameImpl::slotUpdatePreview); | ||||
QObject::connect( m_window, SIGNAL(renameModeChanged(ERenameMode)), &m_renam | connect(m_window, &KRenameWindow::updateCount, | |||
er, SLOT(setRenameMode(ERenameMode))); | this, &KRenameImpl::slotUpdateCount); | |||
QObject::connect( m_window, SIGNAL(filenameTemplateChanged(const QString &)) | ||||
, | connect(m_window, &KRenameWindow::accepted, | |||
&m_renamer, SLOT(setFilenameTemplate(const QString &))); | this, &KRenameImpl::slotStart); | |||
QObject::connect( m_window, SIGNAL(extensionTemplateChanged(const QString &) | ||||
), | QObject::connect(m_window, &KRenameWindow::renameModeChanged, | |||
&m_renamer, SLOT(setExtensionTemplate(const QString &))); | &m_renamer, &BatchRenamer::setRenameMode); | |||
QObject::connect( m_window, SIGNAL(overwriteFilesChanged(bool)), | QObject::connect(m_window, &KRenameWindow::filenameTemplateChanged, | |||
&m_renamer, SLOT(setOverwriteExistingFiles(bool))); | &m_renamer, &BatchRenamer::setFilenameTemplate); | |||
QObject::connect(m_window, &KRenameWindow::extensionTemplateChanged, | ||||
QObject::connect( m_window, SIGNAL(startIndexChanged(int)), | &m_renamer, &BatchRenamer::setExtensionTemplate); | |||
&m_renamer, SLOT(setNumberStartIndex(int))); | QObject::connect(m_window, &KRenameWindow::overwriteFilesChanged, | |||
&m_renamer, &BatchRenamer::setOverwriteExistingFiles); | ||||
connect( m_window, SIGNAL(extensionSplitModeChanged(ESplitMode,int)), SLOT(s | ||||
lotExtensionSplitModeChanged(ESplitMode,int))); | QObject::connect(m_window, &KRenameWindow::startIndexChanged, | |||
&m_renamer, &BatchRenamer::setNumberStartIndex); | ||||
connect( m_window, SIGNAL(showAdvancedNumberingDialog()), SLOT(slotAdvanced | ||||
NumberingDlg())); | connect(m_window, &KRenameWindow::extensionSplitModeChanged, | |||
connect( m_window, SIGNAL(showInsertPartFilenameDialog()), SLOT(slotInsertPa | this, &KRenameImpl::slotExtensionSplitModeChanged); | |||
rtFilenameDlg())); | ||||
connect( m_window, SIGNAL(showFindReplaceDialog()), SLOT(slotFindRepl | connect(m_window, &KRenameWindow::showAdvancedNumberingDialog, | |||
aceDlg())); | this, &KRenameImpl::slotAdvancedNumberingDlg); | |||
connect( m_window, SIGNAL(showTokenHelpDialog(QLineEdit*)),SLOT(slotTokenHel | connect(m_window, &KRenameWindow::showInsertPartFilenameDialog, | |||
pDialog(QLineEdit*))); | this, &KRenameImpl::slotInsertPartFilenameDlg); | |||
connect(m_window, &KRenameWindow::showFindReplaceDialog, | ||||
this, &KRenameImpl::slotFindReplaceDlg); | ||||
connect(m_window, &KRenameWindow::showTokenHelpDialog, | ||||
this, &KRenameImpl::slotTokenHelpDialog); | ||||
} | } | |||
void KRenameImpl::addFileOrDir( const KUrl & url ) | void KRenameImpl::addFileOrDir(const QUrl &url) | |||
{ | { | |||
KRenameFile item( url, m_lastSplitMode, m_lastDot ); | KRenameFile item(url, m_lastSplitMode, m_lastDot); | |||
KRenameFile::List list; | KRenameFile::List list; | |||
list.append( item ); | list.append(item); | |||
m_model->addFiles( list ); | m_model->addFiles(list); | |||
this->slotUpdateCount(); | this->slotUpdateCount(); | |||
} | } | |||
void KRenameImpl::addFilesOrDirs( const KUrl::List & list, const QString & filte | void KRenameImpl::addFilesOrDirs(const QList<QUrl> &list, const QString &filter, | |||
r, | bool recursively, bool dirsWithFiles, bool dirs | |||
bool recursively, bool dirsWithFiles, bool dir | Only, bool hidden) | |||
sOnly, bool hidden ) | ||||
{ | { | |||
KUrl::List::ConstIterator it = list.begin(); | QList<QUrl>::ConstIterator it = list.begin(); | |||
while( it != list.end() ) | while (it != list.end()) { | |||
{ | KRenameFile item(*it, m_lastSplitMode, m_lastDot); | |||
KRenameFile item( *it, m_lastSplitMode, m_lastDot ); | if (item.isDirectory()) { | |||
if( item.isDirectory() ) | QApplication::setOverrideCursor(Qt::BusyCursor); | |||
{ | ||||
KApplication::setOverrideCursor( Qt::BusyCursor ); | ThreadedLister *thl = new ThreadedLister(*it, m_window, m_model); | |||
connect(thl, &ThreadedLister::listerDone, | ||||
ThreadedLister* thl = new ThreadedLister( *it, m_window, m_model ); | this, &KRenameImpl::slotListerDone); | |||
connect( thl, SIGNAL( listerDone( ThreadedLister* ) ), SLOT( slotLis | ||||
terDone( ThreadedLister* ) ) ); | thl->setFilter(filter); | |||
thl->setListDirnamesOnly(dirsOnly); | ||||
thl->setFilter( filter ); | thl->setListHidden(hidden); | |||
thl->setListDirnamesOnly( dirsOnly ); | thl->setListRecursively(recursively); | |||
thl->setListHidden( hidden ); | thl->setListDirnames(dirsWithFiles); | |||
thl->setListRecursively( recursively ); | ||||
thl->setListDirnames( dirsWithFiles ); | ||||
m_runningThreadedListersCount++; | m_runningThreadedListersCount++; | |||
thl->start(); | thl->start(); | |||
} | } else { | |||
else | if (!dirsOnly) { | |||
{ | ||||
if( !dirsOnly ) | ||||
{ | ||||
KRenameFile::List list; | KRenameFile::List list; | |||
list.append( item ); | list.append(item); | |||
m_model->addFiles( list ); | m_model->addFiles(list); | |||
} | } | |||
} | } | |||
++it; | ++it; | |||
} | } | |||
this->slotUpdateCount(); | this->slotUpdateCount(); | |||
} | } | |||
void KRenameImpl::parseCmdLineOptions() | void KRenameImpl::parseCmdLineOptions(QCommandLineParser *parser) | |||
{ | { | |||
bool gotFilenames = false; | bool gotFilenames = false; | |||
KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); | ||||
if( args->isSet( "test" ) ) | if (parser->isSet("test")) { | |||
QTimer::singleShot( 0, this, SLOT( selfTest() ) ); | QTimer::singleShot(0, this, SLOT(selfTest())); | |||
} | ||||
// Add all recursive directoris | // Add all recursive directoris | |||
KUrl::List recursiveList; | QList<QUrl> recursiveList; | |||
QStringList optlist = args->getOptionList ( "r" ); | QStringList directories = parser->values("r"); | |||
for (QStringList::ConstIterator it=optlist.begin(); it!=optlist.end(); ++it) | foreach (const QString &directory, directories) { | |||
{ | QUrl url = QUrl::fromUserInput(directory, QDir::currentPath()); | |||
KUrl url; | ||||
url.setPath( *it ); | ||||
qDebug("Adding recursive: %s", (*it).toUtf8().data()); | qDebug() << "Adding recursive:" << directory; | |||
recursiveList.append( url ); | recursiveList.append(url); | |||
} | } | |||
if( !recursiveList.isEmpty() ) | if (!recursiveList.isEmpty()) { | |||
{ | ||||
gotFilenames = true; | gotFilenames = true; | |||
// Add all directories recursive, but no hiden files | // Add all directories recursive, but no hiden files | |||
this->addFilesOrDirs( recursiveList, "*", true, false, false, false ); | this->addFilesOrDirs(recursiveList, "*", true, false, false, false); | |||
} | } | |||
// Add all files from the commandline options | // Add all files from the commandline options | |||
KUrl::List list; | QList<QUrl> list; | |||
for( int i = 0; i < args->count(); i++) | foreach (const QString &url, parser->positionalArguments()) { | |||
list.append( args->url( i ) ); | list.append(QUrl::fromUserInput(url, QDir::currentPath())); | |||
} | ||||
if( !list.isEmpty() ) | if (!list.isEmpty()) { | |||
{ | ||||
gotFilenames = true; | gotFilenames = true; | |||
} | } | |||
this->addFilesOrDirs( list ); | this->addFilesOrDirs(list); | |||
/* | /* | |||
// load the profile first, so that we do not overwrite other | // load the profile first, so that we do not overwrite other | |||
// commandline settings | // commandline settings | |||
QCString templ = args->getOption( "profile" ); | QCString templ = parser.value( "profile" ); | |||
if( !templ.isEmpty() ) | if( !templ.isEmpty() ) | |||
{ | { | |||
m_hasCommandlineProfile = true; | m_hasCommandlineProfile = true; | |||
ProfileManager::loadProfile( QString( templ ), this ); | ProfileManager::loadProfile( QString( templ ), this ); | |||
} | } | |||
*/ | */ | |||
QString templ = args->getOption( "template" ); | QString templ = parser->value("template"); | |||
if( !templ.isEmpty() ) | if (!templ.isEmpty()) { | |||
m_window->setFilenameTemplate( templ, false ); | m_window->setFilenameTemplate(templ, false); | |||
} | ||||
QString extension = args->getOption( "extension" ); | ||||
if( !extension.isEmpty() ) | ||||
m_window->setExtensionTemplate( extension, false ); | ||||
QString copyDir = args->getOption( "copy" ); | QString extension = parser->value("extension"); | |||
if( !copyDir.isEmpty() ) | if (!extension.isEmpty()) { | |||
{ | m_window->setExtensionTemplate(extension, false); | |||
m_window->setRenameMode( eRenameMode_Copy ); | ||||
m_window->setDestinationUrl( KUrl( copyDir ) ); | ||||
} | } | |||
QString moveDir = args->getOption( "move" ); | QString copyDir = parser->value("copy"); | |||
if( !moveDir.isEmpty() ) | if (!copyDir.isEmpty()) { | |||
{ | m_window->setRenameMode(eRenameMode_Copy); | |||
m_window->setRenameMode( eRenameMode_Move ); | m_window->setDestinationUrl(QUrl(copyDir)); | |||
m_window->setDestinationUrl( KUrl( moveDir ) ); | ||||
} | } | |||
QString linkDir = args->getOption( "link" ); | QString moveDir = parser->value("move"); | |||
if( !linkDir.isEmpty() ) | if (!moveDir.isEmpty()) { | |||
{ | m_window->setRenameMode(eRenameMode_Move); | |||
m_window->setRenameMode( eRenameMode_Link ); | m_window->setDestinationUrl(QUrl(moveDir)); | |||
m_window->setDestinationUrl( KUrl( linkDir ) ); | ||||
} | } | |||
/* | QString linkDir = parser->value("link"); | |||
QCStringList uselist = args->getOptionList ( "use-plugin" ); | if (!linkDir.isEmpty()) { | |||
if( !uselist.isEmpty() ) | m_window->setRenameMode(eRenameMode_Link); | |||
{ | m_window->setDestinationUrl(QUrl(linkDir)); | |||
for(unsigned int i = 0; i < uselist.count(); i++ ) | } | |||
uselist[i] = uselist[i].lower(); | ||||
QPtrListIterator<PluginLoader::PluginLibrary> it( plugin->libs ); | /* | |||
while ( it.current() ) | QCStringList uselist = parser.values ( "use-plugin" ); | |||
if( !uselist.isEmpty() ) | ||||
{ | { | |||
if( uselist.contains( (*it)->plugin->getName().lower().utf8() ) ) | for(unsigned int i = 0; i < uselist.count(); i++ ) | |||
(*it)->check->setChecked( true ); | uselist[i] = uselist[i].lower(); | |||
++it; | QPtrListIterator<PluginLoader::PluginLibrary> it( plugin->libs ); | |||
} | while ( it.current() ) | |||
{ | ||||
if( uselist.contains( (*it)->plugin->getName().lower().utf8() ) | ||||
) | ||||
(*it)->check->setChecked( true ); | ||||
pluginHelpChanged(); | ++it; | |||
} | } | |||
*/ | pluginHelpChanged(); | |||
bool startnow = args->isSet( "start" ); | } | |||
*/ | ||||
bool startnow = parser->isSet("start"); | ||||
// Free some memory | // Free some memory | |||
args->clear(); | ||||
if( gotFilenames ) | if (gotFilenames) { | |||
{ | ||||
// we got already filenames over the commandline, so show directly the l ast | // we got already filenames over the commandline, so show directly the l ast | |||
// page of the wizard | // page of the wizard | |||
m_window->showFilenameTab(); | m_window->showFilenameTab(); | |||
} | } | |||
if( startnow ) | if (startnow) { | |||
{ | qDebug("Waiting for listenters: %i\n", m_runningThreadedListersCount); | |||
qDebug("Waiting for listenters: %i\n", m_runningThreadedListersCount ); | ||||
// As file adding runs in a another trhread, | // As file adding runs in a another trhread, | |||
// there might be adding in progress but not yet | // there might be adding in progress but not yet | |||
// all files in the list. | // all files in the list. | |||
// so let's wait for file adding to finish first | // so let's wait for file adding to finish first | |||
// before starting. | // before starting. | |||
while( m_runningThreadedListersCount > 0 ) | while (m_runningThreadedListersCount > 0) { | |||
kapp->processEvents(); | qApp->processEvents(); | |||
} | ||||
if( m_vector.count() > 0 ) | if (m_vector.count() > 0) | |||
// start renaming | // start renaming | |||
QTimer::singleShot( 200, this, SLOT( slotStart() ) ); | { | |||
QTimer::singleShot(200, this, SLOT(slotStart())); | ||||
} | ||||
} | } | |||
} | } | |||
void KRenameImpl::slotAddFiles() | void KRenameImpl::slotAddFiles() | |||
{ | { | |||
FileDialogExtWidget* widget = new FileDialogExtWidget(); | QPointer<FileDialogExtWidget> dialog = new FileDialogExtWidget(m_window); | |||
KFileDialog dialog( KUrl("kfiledialog://krename"), | ||||
i18n("*|All files and directories"), | ||||
m_window, widget ); | ||||
dialog.setOperationMode( KFileDialog::Opening ); | ||||
dialog.setMode( KFile::Files | KFile::Directory | KFile::ExistingOnly ); | ||||
if( dialog.exec() == QDialog::Accepted ) | if (dialog->exec() == QDialog::Accepted) { | |||
{ | this->addFilesOrDirs(dialog->selectedUrls(), dialog->currentFilter(), | |||
this->addFilesOrDirs( dialog.selectedUrls(), dialog.currentFilter(), | dialog->addRecursively(), dialog->addDirsWithFiles( | |||
widget->addRecursively(), widget->addDirsWithFiles | ), | |||
(), | dialog->addDirsOnly(), dialog->addHidden()); | |||
widget->addDirsOnly(), widget->addHidden() ); | } else { | |||
qWarning() << "Dialog not accepted"; | ||||
} | } | |||
delete dialog; | ||||
} | } | |||
void KRenameImpl::slotRemoveFiles() | void KRenameImpl::slotRemoveFiles() | |||
{ | { | |||
if( m_window->selectedFileItems().count() ) | if (m_window->selectedFileItems().count()) { | |||
{ | m_model->removeFiles(m_window->selectedFileItems()); | |||
m_model->removeFiles( m_window->selectedFileItems() ); | ||||
this->slotUpdateCount(); | this->slotUpdateCount(); | |||
} | } | |||
} | } | |||
void KRenameImpl::slotRemoveAllFiles() | void KRenameImpl::slotRemoveAllFiles() | |||
{ | { | |||
// TODO: Show message box: Do you really want to remove all files. | // TODO: Show message box: Do you really want to remove all files. | |||
if( KMessageBox::questionYesNo( m_window, i18n("Do you really want to remove | if (KMessageBox::questionYesNo(m_window, i18n("Do you really want to remove | |||
all files from the list?"), | all files from the list?"), | |||
i18n("KRename"), KStandardGuiItem::yes(), KS | i18n("KRename"), KStandardGuiItem::yes(), KSt | |||
tandardGuiItem::no(), | andardGuiItem::no(), | |||
"KRenameRemoveAllFromFileList" ) == KMessage | "KRenameRemoveAllFromFileList") == KMessageBo | |||
Box::Yes ) | x::Yes) { | |||
{ | ||||
m_vector.clear(); | m_vector.clear(); | |||
m_window->resetFileList(); | m_window->resetFileList(); | |||
this->slotUpdateCount(); | this->slotUpdateCount(); | |||
} | } | |||
} | } | |||
void KRenameImpl::selfTest() | void KRenameImpl::selfTest() | |||
{ | { | |||
KRenameTest* test = new KRenameTest(); | KRenameTest *test = new KRenameTest(); | |||
test->startTest(); | test->startTest(); | |||
new ModelTest( m_model ); | new ModelTest(m_model); | |||
//new ModelTest( m_previewModel ); | //new ModelTest( m_previewModel ); | |||
// Make _really_ sure it comes to front | // Make _really_ sure it comes to front | |||
test->show(); | test->show(); | |||
test->raise(); | test->raise(); | |||
test->activateWindow(); | test->activateWindow(); | |||
} | } | |||
void KRenameImpl::slotUpdateCount() | void KRenameImpl::slotUpdateCount() | |||
{ | { | |||
m_window->setCount( m_vector.size() ); | m_window->setCount(m_vector.size()); | |||
m_window->slotEnableControls(); | m_window->slotEnableControls(); | |||
this->slotUpdatePreview(); | this->slotUpdatePreview(); | |||
} | } | |||
void KRenameImpl::slotUpdatePreview() | void KRenameImpl::slotUpdatePreview() | |||
{ | { | |||
KApplication::setOverrideCursor( Qt::WaitCursor ); | QApplication::setOverrideCursor(Qt::WaitCursor); | |||
m_renamer.processFilenames(); | m_renamer.processFilenames(); | |||
KApplication::restoreOverrideCursor(); | QApplication::restoreOverrideCursor(); | |||
m_previewModel->refresh(); | m_previewModel->refresh(); | |||
//m_window->m_pageSimple->listPreview->reset(); | //m_window->m_pageSimple->listPreview->reset(); | |||
} | } | |||
void KRenameImpl::slotAdvancedNumberingDlg() | void KRenameImpl::slotAdvancedNumberingDlg() | |||
{ | { | |||
NumberDialog dialog( m_renamer.numberStartIndex(), m_renamer.numberStepping( | QPointer<NumberDialog> dialog = new NumberDialog( | |||
), | m_renamer.numberStartIndex(), m_renamer.numberStepping(), | |||
m_renamer.numberReset(), m_renamer.numberSkipList() ,m_ | m_renamer.numberReset(), m_renamer.numberSkipList(), m_window); | |||
window ); | ||||
if( dialog.exec() == QDialog::Accepted ) | if (dialog->exec() == QDialog::Accepted) { | |||
{ | m_renamer.setNumberStartIndex(dialog->startIndex()); | |||
m_renamer.setNumberStartIndex( dialog.startIndex() ); | m_renamer.setNumberStepping(dialog->numberStepping()); | |||
m_renamer.setNumberStepping( dialog.numberStepping() ); | m_renamer.setNumberReset(dialog->resetCounter()); | |||
m_renamer.setNumberReset( dialog.resetCounter() ); | m_renamer.setNumberSkipList(dialog->skipNumbers()); | |||
m_renamer.setNumberSkipList( dialog.skipNumbers() ); | ||||
m_window->setNumberStartIndex( dialog.startIndex() ); | m_window->setNumberStartIndex(dialog->startIndex()); | |||
slotUpdatePreview(); | slotUpdatePreview(); | |||
} | } | |||
delete dialog; | ||||
} | } | |||
void KRenameImpl::slotInsertPartFilenameDlg() | void KRenameImpl::slotInsertPartFilenameDlg() | |||
{ | { | |||
InsertPartFilenameDlg dialog( m_vector.first().srcFilename() ); | QPointer<InsertPartFilenameDlg> dialog = new InsertPartFilenameDlg(m_vector. first().srcFilename()); | |||
if( dialog.exec() == QDialog::Accepted ) | if (dialog->exec() == QDialog::Accepted) { | |||
{ | m_window->setFilenameTemplate(dialog->command(), true); | |||
m_window->setFilenameTemplate( dialog.command(), true ); | ||||
// Update preview will called from KRenameWindow because of the changed template | // Update preview will called from KRenameWindow because of the changed template | |||
// slotUpdatePreview();s | // slotUpdatePreview();s | |||
} | } | |||
delete dialog; | ||||
} | } | |||
void KRenameImpl::slotFindReplaceDlg() | void KRenameImpl::slotFindReplaceDlg() | |||
{ | { | |||
ReplaceDialog dialog( m_renamer.replaceList(), m_window ); | QPointer<ReplaceDialog> dialog = new ReplaceDialog(m_renamer.replaceList(), m_window); | |||
if( dialog.exec() == QDialog::Accepted ) | if (dialog->exec() == QDialog::Accepted) { | |||
{ | m_renamer.setReplaceList(dialog->replaceList()); | |||
m_renamer.setReplaceList( dialog.replaceList() ); | ||||
slotUpdatePreview(); | slotUpdatePreview(); | |||
} | } | |||
delete dialog; | ||||
} | } | |||
void KRenameImpl::slotListerDone( ThreadedLister* lister ) | void KRenameImpl::slotListerDone(ThreadedLister *lister) | |||
{ | { | |||
// Delete the listener | // Delete the listener | |||
delete lister; | delete lister; | |||
// restore cursor | // restore cursor | |||
KApplication::restoreOverrideCursor(); | QApplication::restoreOverrideCursor(); | |||
// update preview | // update preview | |||
slotUpdateCount(); | slotUpdateCount(); | |||
slotUpdatePreview(); | slotUpdatePreview(); | |||
qDebug("Listener Done ListenersCount: %i", m_runningThreadedListersCount); | qDebug("Listener Done ListenersCount: %i", m_runningThreadedListersCount); | |||
m_runningThreadedListersCount--; | m_runningThreadedListersCount--; | |||
if( m_runningThreadedListersCount < 0 ) | if (m_runningThreadedListersCount < 0) { | |||
{ | ||||
// To be safe | // To be safe | |||
qDebug("m_runningThreadedListersCount=%i", m_runningThreadedListersCount ); | qDebug("m_runningThreadedListersCount=%i", m_runningThreadedListersCount ); | |||
m_runningThreadedListersCount = 0; | m_runningThreadedListersCount = 0; | |||
} | } | |||
} | } | |||
void KRenameImpl::slotTokenHelpDialog(QLineEdit* edit) | void KRenameImpl::slotTokenHelpDialog(QLineEdit *edit) | |||
{ | { | |||
TokenHelpDialog dialog( m_model, &m_renamer, edit, m_window ); | TokenHelpDialog dialog(m_model, &m_renamer, edit, m_window); | |||
// add built-in tokens | // add built-in tokens | |||
QStringList help; | QStringList help; | |||
help.append("$" + TokenHelpDialog::getTokenSeparator() + i18n("old filename" | help.append('$' + TokenHelpDialog::getTokenSeparator() + i18n("old filename" | |||
) ); | )); | |||
help.append("%" + TokenHelpDialog::getTokenSeparator() + i18n("old filename | help.append('%' + TokenHelpDialog::getTokenSeparator() + i18n("old filename | |||
converted to lower case") ); | converted to lower case")); | |||
help.append("&" + TokenHelpDialog::getTokenSeparator() + i18n("old filename | help.append('&' + TokenHelpDialog::getTokenSeparator() + i18n("old filename | |||
converted to upper case") ); | converted to upper case")); | |||
help.append("*" + TokenHelpDialog::getTokenSeparator() + i18n("first letter | help.append('*' + TokenHelpDialog::getTokenSeparator() + i18n("first letter | |||
of every word upper case") ); | of every word upper case")); | |||
help.append("[&1][%2-]" + TokenHelpDialog::getTokenSeparator() + i18n("first | help.append("[&1][%2-]" + TokenHelpDialog::getTokenSeparator() + i18n("first | |||
letter of filename upper case") ); | letter of filename upper case")); | |||
help.append("#" + TokenHelpDialog::getTokenSeparator() + i18n("number (try a | help.append('#' + TokenHelpDialog::getTokenSeparator() + i18n("number (try a | |||
lso ##, ###, ... for leading zeros)") ); | lso ##, ###, ... for leading zeros)")); | |||
help.append("#{0;1}" + TokenHelpDialog::getTokenSeparator() + i18n("counter | help.append("#{0;1}" + TokenHelpDialog::getTokenSeparator() + i18n("counter | |||
with custom start value 0 and custom stepping 1") ); | with custom start value 0 and custom stepping 1")); | |||
help.append("/" + TokenHelpDialog::getTokenSeparator() + i18n("create a subd | help.append('/' + TokenHelpDialog::getTokenSeparator() + i18n("create a subd | |||
irectory") ); | folder")); | |||
help.append("[$x-y]" + TokenHelpDialog::getTokenSeparator() + i18n("characte | help.append("[$x-y]" + TokenHelpDialog::getTokenSeparator() + i18n("characte | |||
r x to y of old filename") ); | r x to y of old filename")); | |||
help.append("[$x;y]" + TokenHelpDialog::getTokenSeparator() + i18n("y charac | help.append("[$x;y]" + TokenHelpDialog::getTokenSeparator() + i18n("y charac | |||
ters of old filename starting at x") ); | ters of old filename starting at x")); | |||
help.append("[$dirname]" + TokenHelpDialog::getTokenSeparator() + i18n("inse | help.append("[$dirname]" + TokenHelpDialog::getTokenSeparator() + i18n("inse | |||
rt name of directory") ); | rt name of folder")); | |||
help.append("[$dirname.]" + TokenHelpDialog::getTokenSeparator() + i18n("ins | help.append("[$dirname.]" + TokenHelpDialog::getTokenSeparator() + i18n("ins | |||
ert name of parent directory") ); | ert name of parent folder")); | |||
help.append("[dirsep]" + TokenHelpDialog::getTokenSeparator() + i18n("insert | help.append("[dirsep]" + TokenHelpDialog::getTokenSeparator() + i18n("insert | |||
a '/' to create a new subdirectory (useful from within regular expressions)") ) | a '/' to create a new subfolder (useful from within regular expressions)")); | |||
; | help.append("[#length-0]" + TokenHelpDialog::getTokenSeparator() + i18n("ins | |||
help.append("[#length-0]" + TokenHelpDialog::getTokenSeparator() + i18n("ins | ert the length of the input filename")); | |||
ert the length of the input filename") ); | help.append("[trimmed]" + TokenHelpDialog::getTokenSeparator() + i18n("strip | |||
help.append("[trimmed]" + TokenHelpDialog::getTokenSeparator() + i18n("strip | whitespaces leading and trailing")); | |||
whitespaces leading and trailing") ); | help.append("[trimmed;.*]" + TokenHelpDialog::getTokenSeparator() + i18n("st | |||
help.append("[trimmed;.*]" + TokenHelpDialog::getTokenSeparator() + i18n("st | rip whitespaces leading and trailing of an arbitrary string")); | |||
rip whitespaces leading and trailing of an arbitrary string") ); | dialog.add(i18n("Built-in Functions"), help, SmallIcon("krename"), true); | |||
dialog.add( i18n("Built-in Functions" ), help, SmallIcon("krename"), true ); | ||||
help.clear(); | help.clear(); | |||
help.append( "\\$" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '$' | help.append("\\$" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '$'" | |||
") ); | )); | |||
help.append( "\\%" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '%' | help.append("\\%" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '%'" | |||
") ); | )); | |||
help.append( "\\&" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '&' | help.append("\\&" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '&'" | |||
") ); | )); | |||
help.append( "\\*" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '*' | help.append("\\*" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '*'" | |||
") ); | )); | |||
help.append( "\\/" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '/' | help.append("\\/" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '/'" | |||
") ); | )); | |||
help.append( "\\\\" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '\ | help.append("\\\\" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '\\ | |||
\\\'") ); | \\'")); | |||
help.append( "\\[" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '[' | help.append("\\[" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '['" | |||
") ); | )); | |||
help.append( "\\]" + TokenHelpDialog::getTokenSeparator() + i18n("Insert ']' | help.append("\\]" + TokenHelpDialog::getTokenSeparator() + i18n("Insert ']'" | |||
") ); | )); | |||
help.append( "\\#" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '#' | help.append("\\#" + TokenHelpDialog::getTokenSeparator() + i18n("Insert '#'" | |||
") ); | )); | |||
dialog.add( i18n("Special Characters" ), help, SmallIcon("krename") ); | dialog.add(i18n("Special Characters"), help, SmallIcon("krename")); | |||
// add plugin tokens | // add plugin tokens | |||
QList<Plugin*>::const_iterator it = m_pluginLoader->plugins().begin(); | QList<Plugin *>::const_iterator it = m_pluginLoader->plugins().begin(); | |||
while( it != m_pluginLoader->plugins().end() ) | while (it != m_pluginLoader->plugins().end()) { | |||
{ | ||||
help.clear(); | help.clear(); | |||
help = (*it)->help(); | help = (*it)->help(); | |||
if( !help.isEmpty() ) | if (!help.isEmpty()) { | |||
dialog.add( (*it)->name(), help, (*it)->icon() ); | dialog.add((*it)->name(), help, (*it)->icon()); | |||
} | ||||
++it; | ++it; | |||
} | } | |||
dialog.exec(); | dialog.exec(); | |||
} | } | |||
void KRenameImpl::slotExtensionSplitModeChanged( ESplitMode splitMode, int dot ) | void KRenameImpl::slotExtensionSplitModeChanged(ESplitMode splitMode, int dot) | |||
{ | { | |||
// only change the splitMode if it has really change since the last time | // only change the splitMode if it has really change since the last time | |||
if( splitMode != m_lastSplitMode || | if (splitMode != m_lastSplitMode || | |||
dot != m_lastDot ) | dot != m_lastDot) { | |||
{ | ||||
KRenameFile::List::iterator it = m_vector.begin(); | KRenameFile::List::iterator it = m_vector.begin(); | |||
while( it != m_vector.end() ) | while (it != m_vector.end()) { | |||
{ | (*it).setCurrentSplitMode(splitMode, dot); | |||
(*it).setCurrentSplitMode( splitMode, dot ); | ||||
++it; | ++it; | |||
} | } | |||
slotUpdatePreview(); | slotUpdatePreview(); | |||
} | } | |||
m_lastSplitMode = splitMode; | m_lastSplitMode = splitMode; | |||
m_lastDot = dot; | m_lastDot = dot; | |||
m_model->setExtensionSplitMode( m_lastSplitMode, m_lastDot ); | m_model->setExtensionSplitMode(m_lastSplitMode, m_lastDot); | |||
} | } | |||
void KRenameImpl::slotStart() | void KRenameImpl::slotStart() | |||
{ | { | |||
ProgressDialog* progress = new ProgressDialog( m_lastSplitMode, m_lastDot ); | ProgressDialog *progress = new ProgressDialog(m_lastSplitMode, m_lastDot); | |||
progress->print( i18n("Starting conversion of %1 files.", m_vector.count()) | progress->print(i18np("Starting conversion of %1 file.", "Starting conversio | |||
); | n of %1 files.", m_vector.count())); | |||
// Get some properties from the gui and initialize BatchRenamer | // Get some properties from the gui and initialize BatchRenamer | |||
const KUrl & destination = m_window->destinationUrl(); | const QUrl &destination = m_window->destinationUrl(); | |||
if( m_renamer.renameMode() != eRenameMode_Rename && | if (m_renamer.renameMode() != eRenameMode_Rename) { | |||
!KIO::NetAccess::exists( destination, true, NULL ) ) | KIO::StatJob *statJob = KIO::stat(destination, KIO::StatJob::Destination | |||
{ | Side, 0); | |||
int m = KMessageBox::warningContinueCancel( m_window, i18n("The director | statJob->exec(); | |||
y %1 does not exist. " | if (statJob->error() == KIO::ERR_DOES_NOT_EXIST) { | |||
"Do you want | int m = KMessageBox::warningContinueCancel(m_window, i18n("The folde | |||
KRename to create it for you?", | r %1 does not exist. " | |||
destinati | "Do you want KRename to create it for you?", | |||
on.prettyUrl() ) ); | destination.toDisplayString(QUrl::PreferLocalFile))); | |||
if( m == KMessageBox::Cancel ) | if (m == KMessageBox::Cancel) { | |||
return; | return; | |||
} | ||||
if( !KIO::NetAccess::mkdir( destination, NULL ) ) | KIO::MkdirJob *job = KIO::mkdir(destination); | |||
{ | KJobWidgets::setWindow(job, m_window); | |||
KMessageBox::error( m_window, i18n("The directory %1 could not be cr | if (!job->exec()) { | |||
eated.").arg( destination.prettyUrl() ) ); | KMessageBox::error(m_window, i18n("The folder %1 could not be cr | |||
return; | eated.", destination.toDisplayString(QUrl::PreferLocalFile))); | |||
return; | ||||
} | ||||
} | } | |||
} | } | |||
m_renamer.setDestinationDir( destination ); | m_renamer.setDestinationDir(destination); | |||
// save the configuration | // save the configuration | |||
// requires access to the window | // requires access to the window | |||
saveConfig(); | saveConfig(); | |||
// Make sure the GUI will not delete our models | // Make sure the GUI will not delete our models | |||
m_window->setModel( NULL ); | m_window->setModel(nullptr); | |||
m_window->setPreviewModel( NULL ); | m_window->setPreviewModel(nullptr); | |||
// show the progress dialog | // show the progress dialog | |||
progress->show(); | progress->show(); | |||
progress->raise(); | progress->raise(); | |||
progress->activateWindow(); | progress->activateWindow(); | |||
// delete the GUI | // delete the GUI | |||
//delete m_window; | //delete m_window; | |||
//m_window = NULL; | //m_window = NULL; | |||
m_window->hide(); | m_window->hide(); | |||
m_window = NULL; | m_window = nullptr; | |||
// Process files with addiational properties which were not | // Process files with additional properties which were not | |||
// necessary or available in the preview | // necessary or available in the preview | |||
m_renamer.processFilenames(); | m_renamer.processFilenames(); | |||
// Do the actual renaming | // Do the actual renaming | |||
m_renamer.processFiles( progress ); | m_renamer.processFiles(progress); | |||
// We are done - ProgressDialog will restart us if necessary | // We are done - ProgressDialog will restart us if necessary | |||
//delete this; | //delete this; | |||
} | } | |||
void KRenameImpl::loadConfig() | void KRenameImpl::loadConfig() | |||
{ | { | |||
KSharedConfigPtr config = KGlobal::config(); | KSharedConfigPtr config = KSharedConfig::openConfig(); | |||
KConfigGroup groupGui = config->group( QString("GUISettings") ); | KConfigGroup groupGui = config->group(QString("GUISettings")); | |||
//groupGui.readEntry( "firststart4", QVariant(true) ).toBool(); | //groupGui.readEntry( "firststart4", QVariant(true) ).toBool(); | |||
m_window->setPreviewEnabled( | m_window->setPreviewEnabled( | |||
groupGui.readEntry( "ImagePreview2", QVariant(true) ).toBool() ); | groupGui.readEntry("ImagePreview2", QVariant(true)).toBool()); | |||
m_window->setPreviewNamesEnabled( | m_window->setPreviewNamesEnabled( | |||
groupGui.readEntry( "ImagePreviewName2", QVariant(true) ).toBool() ); | groupGui.readEntry("ImagePreviewName2", QVariant(true)).toBool()); | |||
KRenameFile::setIconSize(groupGui.readEntry("ImagePreviewSize", QVariant(64) | ||||
).toInt()); | ||||
m_window->setAdvancedMode( | m_window->setAdvancedMode( | |||
groupGui.readEntry( "Advanced", QVariant(false) ).toBool() ); | groupGui.readEntry("Advanced", QVariant(false)).toBool()); | |||
int index = groupGui.readEntry( "StartIndex", QVariant(1) ).toInt(); | int index = groupGui.readEntry("StartIndex", QVariant(1)).toInt(); | |||
int step = groupGui.readEntry( "Stepping", QVariant(1) ).toInt(); | int step = groupGui.readEntry("Stepping", QVariant(1)).toInt(); | |||
m_renamer.setNumberStepping( step ); | m_renamer.setNumberStepping(step); | |||
// Will call batch renamer | // Will call batch renamer | |||
m_window->setNumberStartIndex( index ); | m_window->setNumberStartIndex(index); | |||
int sortMode = groupGui.readEntry( "FileListSorting", QVariant(0) ).toInt(); | int sortMode = groupGui.readEntry("FileListSorting", QVariant(0)).toInt(); | |||
QString customToken = groupGui.readEntry( "FileListSortingCustomToken", | QString customToken = groupGui.readEntry("FileListSortingCustomToken", | |||
m_model->getSortModeCustomToken() | m_model->getSortModeCustomToken()); | |||
); | int customSortModel = groupGui.readEntry("FileListSortingCustomMode", | |||
int customSortModel = groupGui.readEntry( "FileListSortingCustomMode", | QVariant(static_cast<int>(m_model->getSortModeCustomMo | |||
QVariant(static_cast<int>(m_model- | de()))).toInt(); | |||
>getSortModeCustomMode())) ).toInt(); | ||||
m_window->setSortMode(sortMode, customToken, customSortModel); | ||||
m_window->setSortMode( sortMode, customToken, customSortModel ); | ||||
ESplitMode lastSplitMode = static_cast<ESplitMode>(groupGui.readEntry("Exten | ||||
ESplitMode lastSplitMode = static_cast<ESplitMode>(groupGui.readEntry( "Exte | sionSplitMode", static_cast<int>(m_lastSplitMode))); | |||
nsionSplitMode", static_cast<int>(m_lastSplitMode) )); | int lastDot = groupGui.readEntry("ExtensionSplitDot", m_lastDot); | |||
int lastDot = groupGui.readEntry( "ExtensionSplitDot", m_lastDot ); | m_window->setExtensionSplitMode(lastSplitMode, lastDot); | |||
m_window->setExtensionSplitMode( lastSplitMode, lastDot ); | this->slotExtensionSplitModeChanged(lastSplitMode, lastDot); | |||
this->slotExtensionSplitModeChanged( lastSplitMode, lastDot ); | ||||
// load Plugin configuration | // load Plugin configuration | |||
KConfigGroup groupPlugins = config->group( QString("PluginSettings") ); | KConfigGroup groupPlugins = config->group(QString("PluginSettings")); | |||
m_pluginLoader->loadConfig( groupPlugins ); | m_pluginLoader->loadConfig(groupPlugins); | |||
m_window->loadConfig(); | m_window->loadConfig(); | |||
} | } | |||
void KRenameImpl::saveConfig() | void KRenameImpl::saveConfig() | |||
{ | { | |||
// Me might get a saveConfig signal because of signals and slots | // Me might get a saveConfig signal because of signals and slots | |||
// even if m_window was already delted. So ignore these events | // even if m_window was already delted. So ignore these events | |||
if(!m_window) | if (!m_window) { | |||
return; | return; | |||
} | ||||
m_window->saveConfig(); | m_window->saveConfig(); | |||
KSharedConfigPtr config = KGlobal::config(); | KSharedConfigPtr config = KSharedConfig::openConfig(); | |||
KConfigGroup groupGui = config->group( QString("GUISettings") ); | KConfigGroup groupGui = config->group(QString("GUISettings")); | |||
groupGui.writeEntry( "firststart4", false ); | groupGui.writeEntry("firststart4", false); | |||
groupGui.writeEntry( "ImagePreview2", m_window->isPreviewEnabled() ); | groupGui.writeEntry("ImagePreview2", m_window->isPreviewEnabled()); | |||
groupGui.writeEntry( "ImagePreviewName2", m_window->isPreviewNamesEnabled() | groupGui.writeEntry("ImagePreviewName2", m_window->isPreviewNamesEnabled()); | |||
); | groupGui.writeEntry("StartIndex", m_window->numberStartIndex()); | |||
groupGui.writeEntry( "StartIndex", m_window->numberStartIndex() ); | groupGui.writeEntry("Stepping", m_renamer.numberStepping()); | |||
groupGui.writeEntry( "Stepping", m_renamer.numberStepping() ); | groupGui.writeEntry("FileListSorting", m_window->sortMode()); | |||
groupGui.writeEntry( "FileListSorting", m_window->sortMode() ); | groupGui.writeEntry("FileListSortingCustomToken", m_model->getSortModeCustom | |||
groupGui.writeEntry( "FileListSortingCustomToken", m_model->getSortModeCusto | Token()); | |||
mToken() ); | groupGui.writeEntry("FileListSortingCustomMode", static_cast<int>(m_model->g | |||
groupGui.writeEntry( "FileListSortingCustomMode", static_cast<int>(m_model-> | etSortModeCustomMode())); | |||
getSortModeCustomMode()) ); | groupGui.writeEntry("Advanced", m_window->isAdvancedMode()); | |||
groupGui.writeEntry( "Advanced", m_window->isAdvancedMode() ); | groupGui.writeEntry("ExtensionSplitMode", static_cast<int>(m_lastSplitMode)) | |||
groupGui.writeEntry( "ExtensionSplitMode", static_cast<int>(m_lastSplitMode) | ; | |||
); | groupGui.writeEntry("ExtensionSplitDot", m_lastDot); | |||
groupGui.writeEntry( "ExtensionSplitDot", m_lastDot ); | ||||
// save Plugin configuration | // save Plugin configuration | |||
KConfigGroup groupPlugins = config->group( QString("PluginSettings") ); | KConfigGroup groupPlugins = config->group(QString("PluginSettings")); | |||
m_pluginLoader->saveConfig( groupPlugins ); | m_pluginLoader->saveConfig(groupPlugins); | |||
config->sync(); | config->sync(); | |||
} | } | |||
End of changes. 119 change blocks. | ||||
387 lines changed or deleted | 368 lines changed or added |