[go: up one dir, main page]

Menu

[r703]: / tlgselector2.cpp  Maximize  Restore  History

Download this file

115 lines (96 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Marcion
Copyright (C) 2009-2015 Milan Konvicka
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#include "tlgselector2.h"
#include "ui_tlgselector2.h"
CTlgSelector2::CTlgSelector2(
QString const & dir1,
QString const & dir2,
QString const & dir3,
QWidget *parent) :
QDialog(parent),
ui(new Ui::CTlgSelector2)
{
ui->setupUi(this);
QString const * dirs[3]={&dir1,&dir2,&dir3};
for(int y=0;y<=2;y++)
{
IbycusAuthTab at(dirs[y]->toStdString());
for(int x=0;x<at.Count();x++)
{
ui->cmbCorpora->addItem(at.Name(x).c_str());
corpora << QPair<ibystring_t,ibystring_t>(dirs[y]->toStdString(),at.Tag(x));
corpora_id << x;
}
}
//cmbCorpora->setCurrentIndex(0);
on_cmbCorpora_activated(0);
}
CTlgSelector2::~CTlgSelector2()
{
delete ui;
}
//
int CTlgSelector2::line() const{return ui->spnLine->value();}
int CTlgSelector2::chapter() const{return ui->spnChapter->value();}
int CTlgSelector2::verse() const{return ui->spnVerse->value();}
bool CTlgSelector2::utf() const {return ui->rbUtf->isChecked();}
QString CTlgSelector2::selected_corpora() const {return corpora[ui->cmbCorpora->currentIndex()].second.c_str();}
void CTlgSelector2::on_lstAuthor_clicked(QModelIndex )
{
ui->lstWork->clear();
int i=ui->lstAuthor->currentRow();
IbycusTxtFile itxt(author[i].second,author[i].first);
ui->lstWork->clear();
for(int y=0;y<itxt.Count();y++)
for(int x=0;x<itxt.Count(y);x++)
{
ui->lstWork->addItem(QString::number(y+1)+". "+itxt.Name(y,x).c_str());
//work[]
}
}
void CTlgSelector2::on_cmbCorpora_activated(int index)
{
ui->lstAuthor->clear();
ui->lstWork->clear();
author.clear();
int i;
if((i=index)!=-1)
{
IbycusAuthTab at(corpora[i].first);
for(int x=0;x<at.Count(corpora_id[i]);x++)
{
author << QPair<ibystring_t,ibystring_t>(corpora[i].first,at.Id(corpora_id[i],x));
ui->lstAuthor->addItem(at.Name(corpora_id[i],x).c_str());
}
}
}
QPair<ibystring_t,ibystring_t> const & CTlgSelector2::selected_author() const
{
return author[ui->lstAuthor->currentRow()];
}
int CTlgSelector2::selected_work() const
{
return ui->lstWork->currentRow();
}
void CTlgSelector2::on_btCancel_clicked()
{
reject();
}
void CTlgSelector2::on_btOk_clicked()
{
if(ui->lstWork->currentRow()!=-1)
accept();
else
QMessageBox(QMessageBox::Warning,"warning","No work selected.",QMessageBox::Close,this).exec();
}