[go: up one dir, main page]

Menu

[r303]: / tlgselector2.cpp  Maximize  Restore  History

Download this file

98 lines (82 with data), 2.6 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
/* Marcion
Copyright (C) 2009 - 2011 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; version 2 of the License.
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 */
#include "tlgselector2.h"
CTlgSelector2::CTlgSelector2(
QString const & dir1,
QString const & dir2,
QString const & dir3,
QWidget *parent) :
QDialog(parent)
{
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++)
{
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);
}
void CTlgSelector2::on_lstAuthor_clicked(QModelIndex )
{
lstWork->clear();
int i=lstAuthor->currentRow();
IbycusTxtFile itxt(author[i].second,author[i].first);
lstWork->clear();
for(int y=0;y<itxt.Count();y++)
for(int x=0;x<itxt.Count(y);x++)
{
lstWork->addItem(QString::number(y+1)+". "+itxt.Name(y,x).c_str());
//work[]
}
}
void CTlgSelector2::on_cmbCorpora_activated(int index)
{
lstAuthor->clear();
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));
lstAuthor->addItem(at.Name(corpora_id[i],x).c_str());
}
}
}
QPair<ibystring_t,ibystring_t> const & CTlgSelector2::selected_author() const
{
return author[lstAuthor->currentRow()];
}
int CTlgSelector2::selected_work() const
{
return lstWork->currentRow();
}
void CTlgSelector2::on_btCancel_clicked()
{
reject();
}
void CTlgSelector2::on_btOk_clicked()
{
if(lstWork->currentRow()!=-1)
accept();
else
QMessageBox(QMessageBox::Warning,"warning","No work selected.",QMessageBox::Close,this).exec();
}