/* Marcion
Copyright (C) 2009-2013 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 "bookwithverses.h"
CBookWithVerses::CBookWithVerses(QString const & name,
Script script,
TextFormat textFormat,
int key,
Mode ,
CMessages * const messages,
QString const & show_text,
QWidget *parent) :
QWidget(parent),
MDocumentBase(MDocumentBase::MySql),
key(key),mode(Chapter),messages(messages),script(script),textFormat(textFormat),store(),popupSimul(),popupSimulC(),popupSimulL(),_font_offset(0)
{
setupUi(this);
al_remove=popupSimulL.addAction(QIcon(":/new/icons/icons/delete.png"),tr("&remove"));
popupSimulL.addSeparator();
al_rmall=popupSimulL.addAction(tr("r&emove all"));
ac_move=popupSimulC.addAction(QIcon(":/new/icons/icons/go.png"),tr("&add to list"));
popupSimulC.addSeparator();
ac_refresh=popupSimulC.addAction(QIcon(":/new/icons/icons/refresh.png"),tr("&refresh from library"));
a_prev=popupSimul.addAction(QIcon(":/new/icons/icons/uparrow.png"),tr("&previous verse"));
a_next=popupSimul.addAction(QIcon(":/new/icons/icons/downarrow.png"),tr("n&ext verse"));
popupSimul.addSeparator();
a_lead=popupSimul.addAction(tr("&leading book"));
a_lead->setCheckable(true);
a_lead->setChecked(true);
a_wrap=popupSimul.addAction(tr("&word wrap"));
a_wrap->setCheckable(true);
a_wrap->setChecked(true);
popupSimul.addSeparator();
a_dict=popupSimul.addAction(tr("&dictionary (autodetect)"));
a_crum=popupSimul.addAction(QIcon(":/new/icons/icons/gima.png"),tr("search in &Coptic dictionary"));
a_lsj=popupSimul.addAction(QIcon(":/new/icons/icons/alfa2.png"),tr("search in &Gk/Lat dictionary"));
a_searchlib=popupSimul.addAction(QIcon(":/new/icons/icons/loupe.png"),tr("&search in library"));
popupSimul.addSeparator();
a_copy=popupSimul.addAction(QIcon(":/new/icons/icons/copy.png"),tr("c&opy"));
a_copyall=popupSimul.addAction(tr("copy &all"));
popupSimul.addSeparator();
a_incf=popupSimul.addAction(QIcon(":/new/icons/icons/loupe_plus.png"),tr("&larger font"));
a_decf=popupSimul.addAction(QIcon(":/new/icons/icons/loupe_minus.png"),tr("s&maller font"));
a_normf=popupSimul.addAction(tr("&normal font"));
wdgSimul->setVisible(false);
stwSimul->setCurrentIndex(1);
tblSimulTexts->verticalHeader()->setResizeMode(QHeaderView::Fixed);
mspChapter->attachSpinBox(spnChapter);
mspVerse->attachSpinBox(spnVerse);
btCopyExt->setVisible(messages->settings().isCopticEditable());
btCopyExt2->setVisible(messages->settings().isCopticEditable());
setWindowTitle(name);
brBook->init(name,(CBookTextBrowser::Script)script);
if(read_chapters(key))
showBook(key,spnChapter->minimum());
if(!show_text.isEmpty())
{
brBook->setPanelVisibility(true);
brBook->inputBox().setText(show_text);
brBook->inputBox().setSwitchState(true);
}
IC_SIZES
}
void CBookWithVerses::showBook(int book,int chapter)
{
USE_CLEAN_WAIT
CMySql q;
QString query(get_query(book,chapter));
messages->MsgMsg(tr("executing query '")+query+"' ...");
if(!q.exec(query))
{
messages->MsgErr(q.lastError());
return;
}
store.clear();
unsigned int minv(-1),maxv(0);
while(q.next())
{
unsigned int ven(q.value(2).toUInt());
if(ven>maxv)
maxv=ven;
if(ven<minv)
minv=ven;
QString verse("<b><small>("+
q.value(1)+"/"+
QString::number(ven)+")</small></b>"
);
//QString const native_text(q.value(3));
MTextLineItem text_item(q.value(3),true);
text_item.setVerse(verse);
convertTextItem(text_item,textFormat,script);
store.append(text_item);
}
displayStore();
if(mode==Book)
{
spnVerse->setMinimum(0);
spnVerse->setMaximum(9999);
lblVerseMinMax->setText("0+");
mspVerse->setLastVerseActive(false);
}
else
{
spnVerse->setMinimum(minv);
spnVerse->setMaximum(maxv);
lblVerseMinMax->setText(QString::number(minv)+" .. "+QString::number(maxv));
mspVerse->setLastVerseActive(true);
}
findChapter(spnChapter->value(),minv);
messages->MsgOk();
}
void CBookWithVerses::convertTextItem(MTextLineItem & text_item,TextFormat text_format,Script script)
{
switch(text_format)
{
case LatTr :
switch(script)
{
case CTranslit::Latin :
text_item.setText(CTranslit::tr(text_item.text(),CTranslit::LatinTrToLatinN,false,CTranslit::RemoveNone));
break;
case CTranslit::Greek :
text_item.setText(CTranslit::tr(text_item.text(),CTranslit::GreekTrToGreekN,false,CTranslit::RemoveNone));
break;
case CTranslit::Copt :
text_item.setText(CTranslit::tr(text_item.text(),CTranslit::CopticTrToCopticN,false,CTranslit::RemoveNone));
break;
case CTranslit::Hebrew :
text_item.setText(CTranslit::tr(text_item.text(),CTranslit::HebrewTrToHebrewN,false,CTranslit::RemoveNone));
break;
}
break;
case Native :
{
text_item.setText(text_item.text().trimmed());
break;
}
case Beta :
{
text_item.setText(CTranslit::betaToUtf(text_item.text(),(CTranslit::Script)script));
break;
}
}
}
void CBookWithVerses::on_spnChapter_valueChanged(int value)
{
//spnVerse->setValue(1);
switch(mode)
{
case Book :
{
findChapter(spnChapter->value());
break;
}
case Chapter :
{
showBook(key,value);
break;
}
}
if(isSimulActivated())
refresh_simul();
}
void CBookWithVerses::cursorOnTop()
{
QRect const cr(brBook->browser()->cursorRect());
int const scr=brBook->browser()->verticalScrollBar()->value(),
wh=brBook->browser()->viewport()->height();
brBook->browser()->verticalScrollBar()->setValue(scr+cr.top()+(cr.height()/2)-(wh/2));
}
void CBookWithVerses::on_spnVerse_valueChanged(int value)
{
brBook->showPage(CTextBrowserExt::Text);
brBook->browser()->moveCursor(QTextCursor::End);
if(!brBook->browser()->find("("+QString::number(spnChapter->value())+"/"+QString::number(value)+")",
QTextDocument::FindBackward))
brBook->browser()->moveCursor(QTextCursor::Start);
else
cursorOnTop();
if(isSimulActivated())
refresh_simul();
}
void CBookWithVerses::findVerse(int chapter, int verse)
{
spnChapter->setValue(chapter);
spnVerse->setValue(verse);
on_spnVerse_valueChanged(verse);
}
void CBookWithVerses::findChapter(int chapter, int verse)
{
QString v;
if(verse==-1)
spnVerse->setValue(1);
else
{
spnVerse->setValue(verse);
v=QString::number(verse);
}
brBook->browser()->moveCursor(QTextCursor::Start);
if(!brBook->browser()->find("("+QString::number(chapter)+"/"+v))
brBook->browser()->moveCursor(QTextCursor::Start);
else
cursorOnTop();
}
QString CBookWithVerses::get_query(int book, int chapter) const
{
QString query;
switch(mode)
{
case Chapter :
{
query="select * from `library` where `book`="+QString::number(book)+" and `chapter`="+QString::number(chapter)+" order by `verse`";
break;
}
case Book :
{
query="select * from `library` where `book`="+QString::number(book)+" order by `chapter`,`verse`";
break;
}
}
return query;
}
bool CBookWithVerses::read_chapters(int book)
{
CMySql q;
QString query("select min(`chapter`),max(`chapter`) from `library` where `book`="+QString::number(book));
messages->MsgMsg(tr("executing query '")+query+"' ...");
if(!q.exec(query))
{
messages->MsgErr(q.lastError());
return false;
}
if(!q.first())
{
messages->MsgErr("something wrong");
return false;
}
lblChapMinMax->setText(q.value(0)+" .. "+q.value(1));
spnChapter->setMinimum(q.value(0).toInt());
spnChapter->setMaximum(q.value(1).toInt());
spnChapter->setValue(spnChapter->minimum());
messages->MsgOk();
return true;
}
void CBookWithVerses::on_btShow_clicked()
{
on_spnVerse_valueChanged(spnVerse->value());
}
void CBookWithVerses::on_brBook_contentChanged(bool, bool, bool * processed)
{
displayStore();
*processed=true;
}
/*void CBookWithVerses::on_brBook_highlightActivated(bool * processed)
{
displayStore(true);
*processed=true;
}
void CBookWithVerses::on_brBook_highlightDeactivated(bool * processed)
{
displayStore(false);
*processed=true;
}*/
void CBookWithVerses::displayStore(/*bool highlight*/)
{
QString linetemplate(m_sett()->bookRowTemplate());
QString const note_tmpl(m_sett()->noteStyle());
if(!cbTable->isChecked())
{
linetemplate.replace("</td>","(*tab*)");
linetemplate.replace("</tr>","(*break*)");
}
QString atxt;
brBook->browser()->clear();
atxt.append(messages->settings().bookTblTemplate()+"<tbody>");
for(int x=0;x<store.count();x++)
{
QString lt(linetemplate);
QString mtext(store.at(x).text());
if(brBook->rmSpaces())
mtext.remove(" ");
if(brBook->rmAccents()||brBook->rmSpaces())
{
switch(script)
{
case CTranslit::Latin :
mtext=CTranslit::tr(mtext,CTranslit::LatinNToLatinTr,brBook->rmAccents(),brBook->rmSpaces2());
mtext=CTranslit::tr(mtext,CTranslit::LatinTrToLatinN,brBook->rmAccents(),brBook->rmSpaces2());
break;
case CTranslit::Greek :
mtext=CTranslit::tr(mtext,CTranslit::GreekNToGreekTr,brBook->rmAccents(),brBook->rmSpaces2());
mtext=CTranslit::tr(mtext,CTranslit::GreekTrToGreekN,brBook->rmAccents(),brBook->rmSpaces2());
break;
case CTranslit::Copt :
mtext=CTranslit::tr(mtext,CTranslit::CopticNToCopticTr,brBook->rmAccents(),brBook->rmSpaces2());
mtext=CTranslit::tr(mtext,CTranslit::CopticTrToCopticN,brBook->rmAccents(),brBook->rmSpaces2());
break;
case CTranslit::Hebrew :
mtext=CTranslit::tr(mtext,CTranslit::HebrewNToHebrewTr,brBook->rmAccents(),brBook->rmSpaces2());
mtext=CTranslit::tr(mtext,CTranslit::HebrewTrToHebrewN,brBook->rmAccents(),brBook->rmSpaces2());
break;
}
}
/*if(highlight)
mtext=brBook->highlightText(mtext);*/
lt.replace("(*verse*)",store.at(x).verse());
if(store.at(x).hasNote())
{
mtext.append("<p style=\""+note_tmpl+"\">"+store.at(x).note()+"</p>");
}
lt.replace("(*text*)",mtext);
atxt.append(lt);
}
atxt.append("</tbody></table>");
if(!cbTable->isChecked())
{
QRegExp r("<t.*>");
r.setMinimal(true);
atxt.remove(r);
atxt.replace("(*tab*)"," ");
atxt.replace("(*break*)","<br>");
}
brBook->browser()->setHtml(atxt);
brBook->finalizeContent();
brBook->browser()->moveCursor(QTextCursor::Start);
}
void CBookWithVerses::on_cbTable_toggled(bool )
{
brBook->showPage(CTextBrowserExt::Text);
USE_CLEAN_WAIT
displayStore();
}
void CBookWithVerses::on_btCopyExt_clicked()
{
QString t(brBook->browser()->textCursor().selectedText()),
s("*^<a href=\"ext (*name*);(*id*);(*chapter*);(*verse*);(*text*)\">Ext</a>^*");
s.replace("(*text*)",CTranslit::tr(t,CTranslit::CopticNToCopticTr,true,CTranslit::RemoveNone));
s.replace("(*id*)",QString::number(key));
s.replace("(*chapter*)",QString::number(spnChapter->value()));
s.replace("(*verse*)",QString::number(spnVerse->value()));
s.replace("(*name*)",/*lblBookName->text().remove("( ")).replace(")","-"*/windowTitle());
QApplication::clipboard()->setText(s);
}
void CBookWithVerses::on_btCopyExt2_clicked()
{
QString t(brBook->browser()->textCursor().selectedText()),
s(";;(*name*);(*id*);(*chapter*);(*verse*);(*text*)");
s.replace("(*text*)",CTranslit::tr(t,CTranslit::CopticNToCopticTr,true,CTranslit::RemoveNone));
s.replace("(*id*)",QString::number(key));
s.replace("(*chapter*)",QString::number(spnChapter->value()));
s.replace("(*verse*)",QString::number(spnVerse->value()));
s.replace("(*name*)",/*lblBookName->text().remove("( ")).replace(")","-"*/windowTitle());
QApplication::clipboard()->setText(s);
}
void CBookWithVerses::on_btShowPanel_clicked()
{
brBook->showPage(CTextBrowserExt::Text);
brBook->setPanelVisibility(true);
}
void CBookWithVerses::keyPressEvent(QKeyEvent * event)
{
event->ignore();
brBook->keyPressEvent(event);
if(!event->isAccepted())
{
if(event->modifiers()==(Qt::ControlModifier+Qt::ShiftModifier))
{
switch(event->key())
{
case Qt::Key_PageUp :
findVerse(spnChapter->value()+1,spnVerse->value());
event->accept();
break;
case Qt::Key_PageDown :
findVerse(spnChapter->value()-1,spnVerse->value());
event->accept();
break;
default:
//event->ignore();
break;
}
}
if(event->modifiers()==Qt::ControlModifier)
{
switch(event->key())
{
case Qt::Key_PageUp :
findVerse(spnChapter->value(),spnVerse->value()+1);
event->accept();
break;
case Qt::Key_PageDown :
findVerse(spnChapter->value(),spnVerse->value()-1);
event->accept();
break;
default:
//event->ignore();
break;
}
}
if(!event->isAccepted())
QWidget::keyPressEvent(event);
}
}
void CBookWithVerses::on_btBookMode_clicked(bool checked)
{
brBook->showPage(CTextBrowserExt::Text);
if(checked)
mode=Book;
else
mode=Chapter;
showBook(key,spnChapter->value());
}
void CBookWithVerses::on_tbSimul_toggled(bool checked)
{
if(treeSimulLibrary->topLevelItemCount()<1&&checked)
on_tbSimulRefreshLib_clicked();
wdgSimul->setVisible(checked);
if(checked)
refresh_simul();
}
void CBookWithVerses::on_tbSimulAdd_clicked(bool checked)
{
stwSimul->setCurrentIndex(checked?1:0);
}
void CBookWithVerses::on_tbSimulRefreshLib_clicked()
{
m_msg()->libWidget().getSimulBooks(treeSimulLibrary);
}
void CBookWithVerses::on_tbSimulHide_clicked()
{
//wdgSimul->hide();
tbSimul->setChecked(false);
}
void CBookWithVerses::on_tbSimulToList_clicked()
{
QList<QTreeWidgetItem*> l(treeSimulLibrary->selectedItems()),l2;
for(int x=0;x<l.count();x++)
{
CSimulTreeItem * i((CSimulTreeItem *)l.at(x));
if(i->_is_book)
l2.append(i);
}
if(!l2.isEmpty())
{
for(int x=0;x<l2.count();x++)
{
CSimulTreeItem * si((CSimulTreeItem *)l2.at(x));
CSimulTreeItem * sip((CSimulTreeItem *)si->parent());
QString elabel(si->_title);
if(sip)
elabel.prepend(sip->_title+", ");
MSimulItem * mi=new MSimulItem(elabel,si->_id,si->_text_format,si->_script);
connect(mi,SIGNAL(action(int)),this,SLOT(slot_simulAction(int)));
int const rc=tblSimulTexts->rowCount();
tblSimulTexts->insertRow(rc);
tblSimulTexts->setCellWidget(rc,0,mi);
tblSimulTexts->setRowHeight(rc,mi->height());
tblSimulTexts->setCurrentCell(rc,0);
//tblSimulTexts->scrollToItem(tblSimulTexts->item(rc,0),QAbstractItemView::PositionAtBottom);
}
setSimulHeaderLabels();
tblSimulTexts->scrollToBottom();
refresh_simul();
}
else
m_msg()->MsgInf(tr("at least one book must be selected!"));
}
void CBookWithVerses::slot_simulAction(int action)
{
MSimulItem * si((MSimulItem *)this->sender());
if(si)
{
switch(action)
{
case MSimulItem::Close :
{
for(int x=0;x<tblSimulTexts->rowCount();x++)
{
if(si==(MSimulItem *)tblSimulTexts->cellWidget(x,0))
tblSimulTexts->removeRow(x);
}
setSimulHeaderLabels();
refresh_simul();
break;
}
case MSimulItem::Change :
refresh_simul();
break;
}
}
}
bool CBookWithVerses::isSimulActivated() const
{
return tblSimulTexts->rowCount()>0;
}
void CBookWithVerses::refresh_simul()
{
if(!wdgSimul->isVisible())
return;
tbrSimulText->clear();
if(!isSimulActivated())
return;
USE_CLEAN_WAIT
QString lines;
QFont f(m_sett()->bFont((CTranslit::Script)script));
f.setPointSize(f.pointSize()+_font_offset);
tbrSimulText->setFont(f);
int const ch_a(spnChapter->value()),
v_a(spnVerse->value());
if(a_lead->isChecked())
{
QString const ch_a_s(QString::number(ch_a)),
v_a_s(QString::number(v_a));
QString query("select `text` from `library` where `book`="+QString::number(key)+" and `chapter`="+ch_a_s+" and `verse`="+v_a_s);
MQUERY(q,query);
QString textval(tr("not available"));
if(q.first()&&!q.isNULL(0))
textval=q.value(0);
MTextLineItem line_item(textval,true);
convertTextItem(line_item,textFormat,script);
lines.append("<tr><td><b><small>"+ch_a_s+":"+v_a_s+"</small></b></td><td>"+line_item.text()+"</td></tr>");
}
for(int x=0;x<tblSimulTexts->rowCount();x++)
{
MSimulItem * si((MSimulItem *)tblSimulTexts->cellWidget(x,0));
if(si)
{
int const ch=ch_a+si->chapterOffset(),
v=v_a+si->verseOffset(),
book_id=si->bookId();
QString const ch_s(QString::number(ch)),v_s(QString::number(v));
QString query("select `text` from `library` where `book`=*book* and `chapter`=*chapter* and `verse`=*verse*");
query.replace(QString("*book*"),QString::number(book_id));
query.replace(QString("*chapter*"),ch_s);
query.replace(QString("*verse*"),v_s);
MQUERY(q,query);
QString textval(tr("not available"));
if(q.first()&&!q.isNULL(0))
textval=q.value(0);
/*QFont const f(m_sett()->font((CTranslit::Script)si->textScript()));
int const fsize(m_sett()->fontSize((CTranslit::Script)si->textScript()));*/
/*QString const fontspec("font-family: "+f.family()+"; font-size: "+QString::number(fsize+_font_offset)+"pt;");*/
MTextLineItem line_item(textval,true);
convertTextItem(line_item,(TextFormat)si->textFormat(),(Script)si->textScript());
lines.append("<tr><td><b><small>"+ch_s+":"+v_s+"</small></b></td><td>"+m_sett()->spanStringFont(line_item.text(),(CTranslit::Script)si->textScript(),_font_offset)+"</td></tr>");
}
}
tbrSimulText->insertHtml("<table border=\"0\" cellpadding=\"10\" cellspacing=\"0\"><tbody>"+lines+"</tbody></table>");
}
void CBookWithVerses::on_tbSimulUp_clicked()
{
int idx=tblSimulTexts->currentRow();
if(idx>=1)
{
MSimulItem * si((MSimulItem *)tblSimulTexts->cellWidget(idx,0));
tblSimulTexts->insertRow(idx-1);
tblSimulTexts->setCellWidget(idx-1,0,si);
tblSimulTexts->setRowHeight(idx-1,si->height());
tblSimulTexts->removeRow(idx+1);
tblSimulTexts->setCurrentCell(idx-1,0);
setSimulHeaderLabels();
refresh_simul();
}
}
void CBookWithVerses::on_tbSimulDown_clicked()
{
int idx=tblSimulTexts->currentRow();
if(idx<=tblSimulTexts->rowCount()-2)
{
MSimulItem * si((MSimulItem *)tblSimulTexts->cellWidget(idx,0));
tblSimulTexts->insertRow(idx+2);
tblSimulTexts->setCellWidget(idx+2,0,si);
tblSimulTexts->setRowHeight(idx+2,si->height());
tblSimulTexts->removeRow(idx);
tblSimulTexts->setCurrentCell(idx+1,0);
setSimulHeaderLabels();
refresh_simul();
}
}
void CBookWithVerses::on_tbrSimulText_customContextMenuRequested(const QPoint & )
{
bool const sel=tbrSimulText->textCursor().hasSelection();
a_dict->setEnabled(sel);
a_crum->setEnabled(sel);
a_lsj->setEnabled(sel);
a_searchlib->setEnabled(sel);
a_copy->setEnabled(sel);
QAction *a=popupSimul.exec();
if(a)
{
QString const st(tbrSimulText->textCursor().selectedText());
if(a==a_dict)
{
if(!st.isEmpty())
{
if(CTranslit::isCoptic(st))
brBook->find_word(st);
else
brBook->find_greek_word(st);
}
}
else if(a==a_crum)
{
if(!st.isEmpty())
brBook->find_word(st);
}
else if(a==a_lsj)
{
if(!st.isEmpty())
brBook->find_greek_word(st);
}
else if(a==a_searchlib)
{
if(!st.isEmpty())
brBook->searchLibrary(st);
}
else if(a==a_copy)
{
tbrSimulText->copy();
}
else if(a==a_copyall)
{
QTextCursor tc(tbrSimulText->document());
tc.select(QTextCursor::Document);
QApplication::clipboard()->setText(tc.selectedText());
}
else if(a==a_incf)
{
_font_offset+=1;
refresh_simul();
}
else if(a==a_decf)
{
_font_offset-=1;
refresh_simul();
}
else if(a==a_normf)
{
_font_offset=0;
refresh_simul();
}
else if(a==a_lead)
{
refresh_simul();
}
else if(a==a_wrap)
{
tbrSimulText->setWordWrapMode(a_wrap->isChecked()?QTextOption::WordWrap:QTextOption::NoWrap);
}
else if(a==a_next)
{
on_tbSimulNext_clicked();
}
else if(a==a_prev)
{
on_tbSimulPrev_clicked();
}
}
}
void CBookWithVerses::on_tbSimulAction_clicked(bool checked)
{
if(checked)
{
popupSimul.setButton(tbSimulAction);
on_tbrSimulText_customContextMenuRequested(QPoint());
}
}
void CBookWithVerses::on_tbSimulPrev_clicked()
{
mspVerse->on_tbPrev_clicked();
}
void CBookWithVerses::on_tbSimulNext_clicked()
{
mspVerse->on_tbNext_clicked();
}
void CBookWithVerses::on_treeSimulLibrary_customContextMenuRequested(const QPoint &)
{
bool one_book=false;
QList<QTreeWidgetItem*> l(treeSimulLibrary->selectedItems());
for(int x=0;x<l.count();x++)
{
CSimulTreeItem * i=(CSimulTreeItem *)l.at(x);
if(i->_is_book)
{
one_book=true;
break;
}
}
ac_move->setEnabled(one_book);
QAction * a=popupSimulC.exec(QCursor::pos());
if(a)
{
if(a==ac_move)
{
if(one_book)
on_tbSimulToList_clicked();
}
else if(a==ac_refresh)
{
on_tbSimulRefreshLib_clicked();
}
}
}
void CBookWithVerses::on_tblSimulTexts_customContextMenuRequested(const QPoint &)
{
int const idx=tblSimulTexts->currentRow();
al_remove->setEnabled(idx>=0);
QAction * a=popupSimulL.exec(QCursor::pos());
if(a)
{
if(a==al_remove&&idx>=0)
{
MSimulItem * i((MSimulItem *)tblSimulTexts->cellWidget(idx,0));
if(i)
i->on_tbRemove_clicked();
}
else if(a==al_rmall)
{
while(tblSimulTexts->rowCount()>0)
tblSimulTexts->removeRow(0);
refresh_simul();
}
}
}
void CBookWithVerses::setSimulHeaderLabels()
{
int const max=tblSimulTexts->rowCount();
QString const max_s(QString::number(max));
QStringList l;
for(int x=0;x<max;x++)
l.append(QString::number(x+1)+"/"+max_s);
tblSimulTexts->setVerticalHeaderLabels(l);
}
/*void CBookWithVerses::on_tbSimulFontPlus_clicked()
{
_font_offset+=1;
refresh_simul();
}
void CBookWithVerses::on_tbSimulFontMinus_clicked()
{
_font_offset-=1;
refresh_simul();
}*/
//
CSimulTreeItem::CSimulTreeItem(bool is_book,QString const & title,int id,int text_format,int script)
:QTreeWidgetItem(0),
_is_book(is_book),
_title(title),
_id(id),
_text_format(text_format),
_script(script)
{}