insertpartfilenamedlg.cpp (krename-4.0.9) | : | insertpartfilenamedlg.cpp (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 23 | skipping to change at line 23 | |||
* 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 "insertpartfilenamedlg.h" | #include "insertpartfilenamedlg.h" | |||
#include <QDialogButtonBox> | #include <QDialogButtonBox> | |||
#include <QVBoxLayout> | #include <QVBoxLayout> | |||
InsertPartFilenameDlg::InsertPartFilenameDlg( const QString & filename, QWidget* | InsertPartFilenameDlg::InsertPartFilenameDlg(const QString &filename, QWidget *p | |||
parent ) | arent) | |||
: QDialog( parent ), m_start( -1 ), m_end( 0 ) | : QDialog(parent), m_start(-1), m_end(0) | |||
{ | { | |||
QVBoxLayout* layout = new QVBoxLayout( this ); | QVBoxLayout *layout = new QVBoxLayout(this); | |||
QWidget* widget = new QWidget( this ); | QWidget *widget = new QWidget(this); | |||
m_widget.setupUi( widget ); | m_widget.setupUi(widget); | |||
m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::C | m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cl | |||
lose, Qt::Horizontal, this ); | ose, Qt::Horizontal, this); | |||
m_widget.textFilename->setText( filename ); | m_widget.textFilename->setText(filename); | |||
m_widget.textFilename->setCursorPosition( 0 ); | m_widget.textFilename->setCursorPosition(0); | |||
layout->addWidget( widget ); | layout->addWidget(widget); | |||
layout->addWidget( m_buttons ); | layout->addWidget(m_buttons); | |||
connect(m_buttons, SIGNAL(accepted()), this, SLOT(accept())); | connect(m_buttons, &QDialogButtonBox::accepted, | |||
connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject())); | this, &InsertPartFilenameDlg::accept); | |||
connect(m_buttons, &QDialogButtonBox::rejected, | ||||
connect(m_widget.checkInvert, SIGNAL(clicked(bool)), this, SLOT( slotU | this, &InsertPartFilenameDlg::reject); | |||
pdateKRenameCommand() )); | ||||
connect(m_widget.textFilename, SIGNAL(selectionChanged()), this, SLOT( slotS | connect(m_widget.checkInvert, &QCheckBox::clicked, | |||
electionChanged() )); | this, &InsertPartFilenameDlg::slotUpdateKRenameCommand); | |||
connect(m_widget.comboConvert, SIGNAL(currentIndexChanged(int)), this, SLOT( | connect(m_widget.textFilename, &SelectionSafeLineEdit::selectionChanged, | |||
slotSelectionChanged() )); | this, &InsertPartFilenameDlg::slotSelectionChanged); | |||
connect(m_widget.comboConvert, static_cast<void (QComboBox::*)(int)>(&QCombo | ||||
Box::currentIndexChanged), | ||||
this, &InsertPartFilenameDlg::slotSelectionChanged); | ||||
this->slotUpdateKRenameCommand(); | this->slotUpdateKRenameCommand(); | |||
} | } | |||
void InsertPartFilenameDlg::slotSelectionChanged() | void InsertPartFilenameDlg::slotSelectionChanged() | |||
{ | { | |||
m_start = m_widget.textFilename->selectionStart(); | m_start = m_widget.textFilename->selectionStart(); | |||
QString text = m_widget.textFilename->selectedText(); | QString text = m_widget.textFilename->selectedText(); | |||
m_end = m_start + text.length(); | m_end = m_start + text.length(); | |||
skipping to change at line 65 | skipping to change at line 70 | |||
} | } | |||
void InsertPartFilenameDlg::slotUpdateKRenameCommand() | void InsertPartFilenameDlg::slotUpdateKRenameCommand() | |||
{ | { | |||
m_command = ""; | m_command = ""; | |||
bool hasSelected = m_start != -1; | bool hasSelected = m_start != -1; | |||
int cursorPos = m_widget.textFilename->cursorPosition(); | int cursorPos = m_widget.textFilename->cursorPosition(); | |||
int end = m_end; | int end = m_end; | |||
int start = m_start; | int start = m_start; | |||
const char* conversionflag = "$"; | char conversionflag = '$'; | |||
if( m_widget.comboConvert->currentIndex() == 1 ) | if (m_widget.comboConvert->currentIndex() == 1) { | |||
conversionflag = "%"; | conversionflag = '%'; | |||
else if( m_widget.comboConvert->currentIndex() == 2 ) | } else if (m_widget.comboConvert->currentIndex() == 2) { | |||
conversionflag = "&"; | conversionflag = '&'; | |||
else if( m_widget.comboConvert->currentIndex() == 3 ) | } else if (m_widget.comboConvert->currentIndex() == 3) { | |||
conversionflag = "*"; | conversionflag = '*'; | |||
} | ||||
if( !m_widget.textFilename->text().isEmpty() ) | ||||
{ | if (!m_widget.textFilename->text().isEmpty()) { | |||
if( m_widget.checkInvert->isChecked() && hasSelected ) | if (m_widget.checkInvert->isChecked() && hasSelected) { | |||
{ | ||||
// inverted | // inverted | |||
if( end ) | if (end) { | |||
{ | ||||
start++; | start++; | |||
end++; | end++; | |||
if( start > 1 ) | if (start > 1) { | |||
m_command = QString("[%1;%2]").arg(conversionflag).arg(start | m_command = QString("[%1;%2]").arg(conversionflag).arg(start | |||
-1); | - 1); | |||
} | ||||
if( end <= (signed int)m_widget.textFilename->text().length() ) | ||||
m_command.append( QString("[%1%2-[length]]").arg(conversionf | if (end <= (signed int)m_widget.textFilename->text().length()) { | |||
lag).arg(end) ); | m_command.append(QString("[%1%2-[length]]").arg(conversionfl | |||
ag).arg(end)); | ||||
} | ||||
} | } | |||
} | } else if (m_widget.checkInvert->isChecked() && !hasSelected) { | |||
else if( m_widget.checkInvert->isChecked() && !hasSelected ) | m_command = QString("[%1").arg(conversionflag) + QString("1;%1][%3%2 | |||
{ | -[length]]").arg(cursorPos).arg(cursorPos + 1); | |||
m_command = QString("[%1").arg(conversionflag) + QString("1;%1][%3%2 | } else if (!m_widget.checkInvert->isChecked() && hasSelected) { | |||
-[length]]").arg(cursorPos).arg(cursorPos+1); | if (end) { | |||
} | ||||
else if( !m_widget.checkInvert->isChecked() && hasSelected ) | ||||
{ | ||||
if( end ) | ||||
{ | ||||
start++; | start++; | |||
end++; | end++; | |||
if( end <= (signed int)m_widget.textFilename->text().length() ) | if (end <= (signed int)m_widget.textFilename->text().length()) { | |||
m_command = QString("[%1%2;%3]").arg(conversionflag).arg(sta | m_command = QString("[%1%2;%3]").arg(conversionflag).arg(sta | |||
rt).arg(end-start); | rt).arg(end - start); | |||
else | } else { | |||
m_command = QString("[%1%2-[length]]").arg(conversionflag).a rg(start); | m_command = QString("[%1%2-[length]]").arg(conversionflag).a rg(start); | |||
} | ||||
} | } | |||
} | } else if (!m_widget.checkInvert->isChecked() && !hasSelected) { | |||
else if( !m_widget.checkInvert->isChecked() && !hasSelected ) | m_command = QString("[%1%2-[length]]").arg(conversionflag).arg(curso | |||
{ | rPos); | |||
m_command = QString("[%1%2-[length]]").arg(conversionflag).arg( curs | ||||
orPos ); | ||||
} | } | |||
} | } | |||
m_widget.labelPreview->setText( m_command ); | m_widget.labelPreview->setText(m_command); | |||
} | } | |||
#include "insertpartfilenamedlg.moc" | ||||
End of changes. 14 change blocks. | ||||
63 lines changed or deleted | 60 lines changed or added |