summaryrefslogtreecommitdiffstats
path: root/kate/katesort/src/sortdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kate/katesort/src/sortdialog.cpp')
-rw-r--r--kate/katesort/src/sortdialog.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/kate/katesort/src/sortdialog.cpp b/kate/katesort/src/sortdialog.cpp
new file mode 100644
index 0000000..d46746b
--- /dev/null
+++ b/kate/katesort/src/sortdialog.cpp
@@ -0,0 +1,144 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Marian Kyral *
+ * mkyral@email.cz *
+ * *
+ * 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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#include "sortdialog.h"
+#include "kconfig.h"
+#include <qwhatsthis.h>
+
+SortDialog::SortDialog ( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : sortdialoglayout ( parent,name, modal,fl )
+{
+ // set labels
+ QWhatsThis::add(m_radioButtonAsc,i18n(
+ "Sort in ascending order "
+ "(from A to Z or 0 to 9)."));
+ QWhatsThis::add(m_radioButtonDesc,i18n(
+ "Sort in descending order "
+ "(from Z to A or 9 to 0)."));
+ QWhatsThis::add(m_checkBoxCase,i18n(
+ "Check this for case sensitive sort."));
+ QWhatsThis::add(m_checkBoxUnique,i18n(
+ "Check this to removed all duplicated records."));
+ QWhatsThis::add(m_checkBoxByCol,i18n(
+ "Check this for sorting by specific column.\n\n"
+ "If a part of one line is selected, "
+ "this checkbox is automatically selected. "
+ "Start and end fields are filled according to selection."));
+ QWhatsThis::add(m_lineEditStartCol,i18n(
+ "Start column of the sorting area."));
+ QWhatsThis::add(m_lineEditEndCol,i18n(
+ "End column of the sorting area."));
+ QWhatsThis::add(m_radioButtonAlphaSort,i18n(
+ "Alphabetical sorting (A-Z)."));
+ QWhatsThis::add(m_radioButtonNumSort,i18n(
+ "Numeric sorting (0-9)"));
+
+ config_load();
+}
+
+SortDialog::~SortDialog()
+{}
+
+/*$SPECIALIZATION$*/
+void SortDialog::reject()
+{
+ QDialog::reject();
+}
+
+void SortDialog::accept()
+{
+ if (m_checkBoxByCol->isChecked())
+ {
+ if (m_lineEditStartCol->text().isEmpty() ||
+ m_lineEditStartCol->text().toInt() == 0 ||
+ m_lineEditEndCol->text().isEmpty() ||
+ m_lineEditEndCol->text().toInt() == 0)
+ {
+ QMessageBox::warning(this,i18n("Error"),
+ i18n("Fields:\n\"Starting at\" and \"Ending at\"\nhave to contains numbers."),
+ i18n("OK"));
+ return;
+ }
+ }
+ config_save();
+ QDialog::accept();
+}
+
+int SortDialog::exec()
+{
+ return QDialog::exec();
+}
+
+void SortDialog::toggledCol()
+{
+ if (m_lineEditStartCol->isEnabled())
+ {
+ m_lineEditStartCol->setEnabled(false);
+ m_lineEditEndCol->setEnabled(false);
+ }
+ else
+ {
+ m_lineEditStartCol->setEnabled(true);
+ m_lineEditEndCol->setEnabled(true);
+ }
+}
+
+void SortDialog::toggledType()
+{
+ if (m_radioButtonAlphaSort->isChecked())
+ m_checkBoxCase->setEnabled(true);
+ else
+ m_checkBoxCase->setEnabled(false);
+}
+
+void SortDialog::config_load ()
+{
+// qDebug("config_load()");
+ KConfig *config = new KConfig("katesortpluginrc");
+ m_radioButtonAsc->setChecked(config->readBoolEntry("Asc",true));
+ m_radioButtonDesc->setChecked(config->readBoolEntry("Desc",false));
+ m_radioButtonAlphaSort->setChecked(config->readBoolEntry("Alpha",true));
+ m_radioButtonNumSort->setChecked(config->readBoolEntry("Num",false));
+ m_checkBoxCase->setChecked(config->readBoolEntry("Case",false));
+ m_checkBoxUnique->setChecked(config->readBoolEntry("Unique",false));
+ m_checkBoxByCol->setChecked(config->readBoolEntry("By col",false));
+ m_lineEditStartCol->setText(config->readEntry("Start col"));
+ m_lineEditEndCol->setText(config->readEntry("End col"));
+}
+
+void SortDialog::config_save ()
+{
+// qDebug("config_save()");
+ KConfig *config = new KConfig("katesortpluginrc");
+ config->writeEntry("Asc",m_radioButtonAsc->isOn());
+ config->writeEntry("Desc", m_radioButtonDesc->isOn());
+ config->writeEntry("Alpha",m_radioButtonAlphaSort->isOn());
+ config->writeEntry("Num", m_radioButtonNumSort->isOn());
+ config->writeEntry("Case", m_checkBoxCase->isOn());
+ config->writeEntry("Unique", m_checkBoxUnique->isOn());
+ config->writeEntry("By col", m_checkBoxByCol->isOn());
+ config->writeEntry("Start col", m_lineEditStartCol->text());
+ config->writeEntry("End col", m_lineEditEndCol->text());
+ config->sync();
+}
+
+#include "sortdialog.moc"
+