You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
5.1 KiB
145 lines
5.1 KiB
11 years ago
|
/***************************************************************************
|
||
|
* 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"
|
||
11 years ago
|
#include "tdeconfig.h"
|
||
11 years ago
|
#include <tqwhatsthis.h>
|
||
11 years ago
|
|
||
11 years ago
|
SortDialog::SortDialog ( TQWidget* parent, const char* name, bool modal, WFlags fl )
|
||
11 years ago
|
: sortdialoglayout ( parent,name, modal,fl )
|
||
|
{
|
||
|
// set labels
|
||
11 years ago
|
TQWhatsThis::add(m_radioButtonAsc,i18n(
|
||
11 years ago
|
"Sort in ascending order "
|
||
|
"(from A to Z or 0 to 9)."));
|
||
11 years ago
|
TQWhatsThis::add(m_radioButtonDesc,i18n(
|
||
11 years ago
|
"Sort in descending order "
|
||
|
"(from Z to A or 9 to 0)."));
|
||
11 years ago
|
TQWhatsThis::add(m_checkBoxCase,i18n(
|
||
11 years ago
|
"Check this for case sensitive sort."));
|
||
11 years ago
|
TQWhatsThis::add(m_checkBoxUnique,i18n(
|
||
11 years ago
|
"Check this to removed all duplicated records."));
|
||
11 years ago
|
TQWhatsThis::add(m_checkBoxByCol,i18n(
|
||
11 years ago
|
"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."));
|
||
11 years ago
|
TQWhatsThis::add(m_lineEditStartCol,i18n(
|
||
11 years ago
|
"Start column of the sorting area."));
|
||
11 years ago
|
TQWhatsThis::add(m_lineEditEndCol,i18n(
|
||
11 years ago
|
"End column of the sorting area."));
|
||
11 years ago
|
TQWhatsThis::add(m_radioButtonAlphaSort,i18n(
|
||
11 years ago
|
"Alphabetical sorting (A-Z)."));
|
||
11 years ago
|
TQWhatsThis::add(m_radioButtonNumSort,i18n(
|
||
11 years ago
|
"Numeric sorting (0-9)"));
|
||
|
|
||
|
config_load();
|
||
|
}
|
||
|
|
||
|
SortDialog::~SortDialog()
|
||
|
{}
|
||
|
|
||
|
/*$SPECIALIZATION$*/
|
||
|
void SortDialog::reject()
|
||
|
{
|
||
11 years ago
|
TQDialog::reject();
|
||
11 years ago
|
}
|
||
|
|
||
|
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)
|
||
|
{
|
||
11 years ago
|
TQMessageBox::warning(this,i18n("Error"),
|
||
11 years ago
|
i18n("Fields:\n\"Starting at\" and \"Ending at\"\nhave to contains numbers."),
|
||
|
i18n("OK"));
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
config_save();
|
||
11 years ago
|
TQDialog::accept();
|
||
11 years ago
|
}
|
||
|
|
||
|
int SortDialog::exec()
|
||
|
{
|
||
11 years ago
|
return TQDialog::exec();
|
||
11 years ago
|
}
|
||
|
|
||
|
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 ()
|
||
|
{
|
||
11 years ago
|
// tqDebug("config_load()");
|
||
11 years ago
|
TDEConfig *config = new TDEConfig("katesortpluginrc");
|
||
11 years ago
|
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 ()
|
||
|
{
|
||
11 years ago
|
// tqDebug("config_save()");
|
||
11 years ago
|
TDEConfig *config = new TDEConfig("katesortpluginrc");
|
||
11 years ago
|
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"
|
||
|
|