|
|
@ -26,7 +26,7 @@
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
#include <qregexp.h>
|
|
|
|
#include <tqregexp.h>
|
|
|
|
|
|
|
|
|
|
|
|
class PluginView : public KXMLGUIClient
|
|
|
|
class PluginView : public KXMLGUIClient
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -55,14 +55,14 @@ KatePluginFactory::~KatePluginFactory()
|
|
|
|
delete s_instance;
|
|
|
|
delete s_instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QObject* KatePluginFactory::createObject( QObject* parent, const char* name, const char*, const QStringList & )
|
|
|
|
TQObject* KatePluginFactory::createObject( TQObject* parent, const char* name, const char*, const TQStringList & )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new KatePluginSort( parent, name );
|
|
|
|
return new KatePluginSort( parent, name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KInstance* KatePluginFactory::s_instance = 0L;
|
|
|
|
KInstance* KatePluginFactory::s_instance = 0L;
|
|
|
|
|
|
|
|
|
|
|
|
KatePluginSort::KatePluginSort( QObject* parent, const char* name )
|
|
|
|
KatePluginSort::KatePluginSort( TQObject* parent, const char* name )
|
|
|
|
: Kate::Plugin ( (Kate::Application*)parent, name )
|
|
|
|
: Kate::Plugin ( (Kate::Application*)parent, name )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,13 +120,13 @@ void KatePluginSort::slotSort()
|
|
|
|
if (! (sel_sc == 0 && (int) sel_ec == kv->getDoc()->lineLength(kv->getDoc()->selStartLine())))
|
|
|
|
if (! (sel_sc == 0 && (int) sel_ec == kv->getDoc()->lineLength(kv->getDoc()->selStartLine())))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_sortDialog.m_checkBoxByCol->setChecked(true);
|
|
|
|
m_sortDialog.m_checkBoxByCol->setChecked(true);
|
|
|
|
m_sortDialog.m_lineEditStartCol->setText(QString::number(sel_sc,10));
|
|
|
|
m_sortDialog.m_lineEditStartCol->setText(TQString::number(sel_sc,10));
|
|
|
|
m_sortDialog.m_lineEditEndCol->setText(QString::number(sel_ec,10));
|
|
|
|
m_sortDialog.m_lineEditEndCol->setText(TQString::number(sel_ec,10));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kv->getDoc()->clearSelection();
|
|
|
|
kv->getDoc()->clearSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_sortDialog.exec() == QDialog::Rejected)
|
|
|
|
if (m_sortDialog.exec() == TQDialog::Rejected)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (kv->getDoc()->selection().isEmpty())
|
|
|
|
if (kv->getDoc()->selection().isEmpty())
|
|
|
@ -142,15 +142,15 @@ void KatePluginSort::slotSort()
|
|
|
|
sel_el-- ;
|
|
|
|
sel_el-- ;
|
|
|
|
|
|
|
|
|
|
|
|
// split string to lines
|
|
|
|
// split string to lines
|
|
|
|
QStringMultiMap strMLines; // alphabetical sort multimap
|
|
|
|
TQStringMultiMap strMLines; // alphabetical sort multimap
|
|
|
|
LongMultiMap longMLines; // numerical sort multimap
|
|
|
|
LongMultiMap longMLines; // numerical sort multimap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Map filling...
|
|
|
|
// Map filling...
|
|
|
|
QString skey;
|
|
|
|
TQString skey;
|
|
|
|
QString sdata;
|
|
|
|
TQString sdata;
|
|
|
|
int ikey, non_num_ind;
|
|
|
|
int ikey, non_num_ind;
|
|
|
|
QRegExp rx("[^0-9]"); // Search regexp for not number character
|
|
|
|
TQRegExp rx("[^0-9]"); // Search regexp for not number character
|
|
|
|
for (uint i = sel_sl; i <= sel_el; i++)
|
|
|
|
for (uint i = sel_sl; i <= sel_el; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sdata = kv->getDoc()->textLine(i);
|
|
|
|
sdata = kv->getDoc()->textLine(i);
|
|
|
@ -159,22 +159,22 @@ void KatePluginSort::slotSort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
skey = skey.mid(m_sortDialog.m_lineEditStartCol->text().toInt() - 1,
|
|
|
|
skey = skey.mid(m_sortDialog.m_lineEditStartCol->text().toInt() - 1,
|
|
|
|
m_sortDialog.m_lineEditEndCol->text().toInt() - m_sortDialog.m_lineEditStartCol->text().toInt());
|
|
|
|
m_sortDialog.m_lineEditEndCol->text().toInt() - m_sortDialog.m_lineEditStartCol->text().toInt());
|
|
|
|
// qDebug("skey: %s", skey.ascii());
|
|
|
|
// tqDebug("skey: %s", skey.ascii());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// qDebug("\tLine: %d",i);
|
|
|
|
// tqDebug("\tLine: %d",i);
|
|
|
|
// qDebug("Key: %s, Line content: %s", skey.ascii(),sdata.ascii());
|
|
|
|
// tqDebug("Key: %s, Line content: %s", skey.ascii(),sdata.ascii());
|
|
|
|
if (m_sortDialog.m_radioButtonAlphaSort->isChecked())
|
|
|
|
if (m_sortDialog.m_radioButtonAlphaSort->isChecked())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_sortDialog.m_checkBoxCase->isChecked())
|
|
|
|
if (m_sortDialog.m_checkBoxCase->isChecked())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Case sensitive sort
|
|
|
|
// Case sensitive sort
|
|
|
|
strMLines.insert(std::pair<QString, QString>(skey ,sdata));
|
|
|
|
strMLines.insert(std::pair<TQString, TQString>(skey ,sdata));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Case insensitive sort
|
|
|
|
// Case insensitive sort
|
|
|
|
strMLines.insert(std::pair<QString, QString>(skey.lower(), sdata));
|
|
|
|
strMLines.insert(std::pair<TQString, TQString>(skey.lower(), sdata));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -186,7 +186,7 @@ void KatePluginSort::slotSort()
|
|
|
|
non_num_ind = skey.find(rx,0);
|
|
|
|
non_num_ind = skey.find(rx,0);
|
|
|
|
if (non_num_ind != -1)
|
|
|
|
if (non_num_ind != -1)
|
|
|
|
{ // beginning of key is number
|
|
|
|
{ // beginning of key is number
|
|
|
|
// qDebug("non_num_ind: %d",non_num_ind);
|
|
|
|
// tqDebug("non_num_ind: %d",non_num_ind);
|
|
|
|
skey.truncate(non_num_ind);
|
|
|
|
skey.truncate(non_num_ind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -194,8 +194,8 @@ void KatePluginSort::slotSort()
|
|
|
|
skey = "0";
|
|
|
|
skey = "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// qDebug("Key: %s",skey.ascii());
|
|
|
|
// tqDebug("Key: %s",skey.ascii());
|
|
|
|
longMLines.insert(std::pair<long, QString>(skey.toLong(), sdata));
|
|
|
|
longMLines.insert(std::pair<long, TQString>(skey.toLong(), sdata));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -204,12 +204,12 @@ void KatePluginSort::slotSort()
|
|
|
|
kv->getDoc()->removeText(sel_sl,0,sel_el,kv->getDoc()->lineLength(sel_el));
|
|
|
|
kv->getDoc()->removeText(sel_sl,0,sel_el,kv->getDoc()->lineLength(sel_el));
|
|
|
|
// kv->updateView(false);
|
|
|
|
// kv->updateView(false);
|
|
|
|
|
|
|
|
|
|
|
|
QStringMultiMap::iterator smit, smsit, emsit;
|
|
|
|
TQStringMultiMap::iterator smit, smsit, emsit;
|
|
|
|
LongMultiMap::iterator lmit, slmit, elmit;
|
|
|
|
LongMultiMap::iterator lmit, slmit, elmit;
|
|
|
|
bool fasc;
|
|
|
|
bool fasc;
|
|
|
|
uint i=sel_sl; // insert start line
|
|
|
|
uint i=sel_sl; // insert start line
|
|
|
|
bool first=true; // First line flag
|
|
|
|
bool first=true; // First line flag
|
|
|
|
QString prevLine; // Store previous line (for unique purpose)
|
|
|
|
TQString prevLine; // Store previous line (for unique purpose)
|
|
|
|
|
|
|
|
|
|
|
|
if (m_sortDialog.m_radioButtonAlphaSort->isChecked())
|
|
|
|
if (m_sortDialog.m_radioButtonAlphaSort->isChecked())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -233,13 +233,13 @@ void KatePluginSort::slotSort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sdata = smit->second;
|
|
|
|
sdata = smit->second;
|
|
|
|
skey = smit->first;
|
|
|
|
skey = smit->first;
|
|
|
|
// qDebug("Key: %s, Line content: %s", skey.ascii(),sdata.ascii());
|
|
|
|
// tqDebug("Key: %s, Line content: %s", skey.ascii(),sdata.ascii());
|
|
|
|
|
|
|
|
|
|
|
|
if (m_sortDialog.m_checkBoxUnique->isChecked())
|
|
|
|
if (m_sortDialog.m_checkBoxUnique->isChecked())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( prevLine.compare(sdata) != 0 || first ) //remove duplicities
|
|
|
|
if ( prevLine.compare(sdata) != 0 || first ) //remove duplicities
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// qDebug("Inserting line: %d",i);
|
|
|
|
// tqDebug("Inserting line: %d",i);
|
|
|
|
first = false;
|
|
|
|
first = false;
|
|
|
|
prevLine = sdata;
|
|
|
|
prevLine = sdata;
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
@ -249,7 +249,7 @@ void KatePluginSort::slotSort()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prevLine = sdata;
|
|
|
|
prevLine = sdata;
|
|
|
|
// qDebug("Inserting line: %d",i);
|
|
|
|
// tqDebug("Inserting line: %d",i);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
} // m_sortDialog.m_checkBoxUnique->isChecked()
|
|
|
|
} // m_sortDialog.m_checkBoxUnique->isChecked()
|
|
|
@ -278,12 +278,12 @@ void KatePluginSort::slotSort()
|
|
|
|
sdata = lmit->second;
|
|
|
|
sdata = lmit->second;
|
|
|
|
ikey = lmit->first;
|
|
|
|
ikey = lmit->first;
|
|
|
|
|
|
|
|
|
|
|
|
// qDebug("Key: %d, Line content: %s", ikey,sdata.ascii());
|
|
|
|
// tqDebug("Key: %d, Line content: %s", ikey,sdata.ascii());
|
|
|
|
if (m_sortDialog.m_checkBoxUnique->isChecked())
|
|
|
|
if (m_sortDialog.m_checkBoxUnique->isChecked())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( prevLine.compare(sdata) != 0 || first ) //remove duplicities
|
|
|
|
if ( prevLine.compare(sdata) != 0 || first ) //remove duplicities
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// qDebug("Inserting line: %d",i);
|
|
|
|
// tqDebug("Inserting line: %d",i);
|
|
|
|
first = false;
|
|
|
|
first = false;
|
|
|
|
prevLine = sdata;
|
|
|
|
prevLine = sdata;
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
@ -293,7 +293,7 @@ void KatePluginSort::slotSort()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prevLine = sdata;
|
|
|
|
prevLine = sdata;
|
|
|
|
// qDebug("Inserting line: %d",i);
|
|
|
|
// tqDebug("Inserting line: %d",i);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
kv->getDoc()->insertLine(i, sdata);
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
} // m_sortDialog.m_checkBoxUnique->isChecked()
|
|
|
|
} // m_sortDialog.m_checkBoxUnique->isChecked()
|
|
|
|