BBSView::BBSView(QWidget *parent) : QWidget(parent), m_favorites(0)
{
- /* copied from Base class */
+ // copied from Base class
bbsViewBaseLayout = new QVBoxLayout(this);
layout10 = new QHBoxLayout(0);
m_boardList->setRootIsDecorated(true);
bbsViewBaseLayout->addWidget(m_boardList);
resize(QSize(600, 482).expandedTo(minimumSizeHint()));
- /* copy end */
+ // copy end
m_boardList->setHeaderLabel(i18nc("@title:column", "Board Name"));
m_boardList->header()->setClickable(false);
QList<Category> categoryList = getCategoryList(html);
QList<Category>::iterator it;
- /* Are there new boards or moved boards ? */
+ // Are there new boards or moved boards?
QString newBoards;
QString oldBoards;
for (it = categoryList.begin(); it != categoryList.end(); ++it) {
const int maxNewBoard = 64;
- /* show new board names */
+ // show new board names
if (!newBoards.isEmpty() && newBoards.count("\n") < maxNewBoard) {
QStringList boardList = newBoards.split('\n');
boardList, "Kita");
}
- /* show moved board names */
+ // show moved board names
if (!oldBoards.isEmpty()) {
QStringList boardList = oldBoards.split('\n');
db.moveBoard(oldUrl, newUrl);
}
- /* save config */
+ // save config
QString configPath = KStandardDirs::locateLocal("appdata", "board_list");
KConfig config(configPath);
for (it = categoryList.begin(); it != categoryList.end(); ++it) {
m_readNum = 0;
m_newNum = 0;
- /* get list of pointers of Thread classes */
+ // get list of pointers of Thread classes
QList<Thread*> oldLogList;
QList<Thread*> threadList;
BoardDatabase db(m_boardUrl);
subjectList->setFocus();
updateKindLabel();
- /* restore column size */
+ // restore column size
loadLayout();
loadHeaderOnOff();
m_enableSizeChange = true;
subjectList->item(row, ColumnSpeed)
->setText(QString(" %1 ").arg(speed, 0, 'f', 2));
- /* set mark order */
+ // set mark order
QTableWidgetItem *item = subjectList->item(row, ColumnMark);
int orderValue;
- if (!id) { /* old thread */
+ if (!id) { // old thread
orderValue = ThreadOld;
} else if (readNum > 0 && (resNum > readNum || resNum > viewPos)) {
- /* There are new responses. */
+ // There are new responses.
item->setIcon(QIcon(SmallIcon("unread")));
m_unreadNum++;
orderValue = ThreadHasUnread;
- } else if (readNum > 0) { /* Cache exists */
+ } else if (readNum > 0) { // Cache exists
item->setIcon(QIcon(SmallIcon("read")));
m_readNum++;
orderValue = (viewPos > 1000) ? ThreadReaded : ThreadRead;
} else if (since.secsTo(current) < 3600 * GlobalConfig::markTime()) {
- /* new thread */
+ // new thread
item->setIcon(QIcon(SmallIcon("newthread")));
m_newNum++;
orderValue = ThreadNew;
- } else { /* normal */
+ } else { // normal
item->setIcon(QIcon());
orderValue = ThreadNormal;
}
// no effect: m_unreadNum, m_readNum, m_newNum, markOrder
if (datManager.isMainThreadOpened() && resNum == readNum) {
- /* opened */
+ // opened
subjectList->item(row, ColumnMark)->setIcon(QIcon(SmallIcon("open")));
}
}
m_bufSize = 0;
m_bottomNum = 0;
- /* create the nodes of footer, header, etc. */
+ // create the nodes of footer, header, etc.
createKokoyon();
createFooter();
createHeader();
- /* get pointer of DatInfo */
- /* Note that m_datURL is already locked in the HTMLPart. */
+ // get pointer of DatInfo
+ // Note that m_datURL is already locked in the HTMLPart.
m_datInfo = DatManager(datUrl).getDatInfoPointer();
}
Q_ASSERT(m_datInfo != 0);
if (num < m_bufSize && m_resStatus[ num ] != HTML_NOTPARSED) {
- /* already parsed */
+ // already parsed
return true;
}
if (num >= m_bufSize) {
- /* resize buffer size */
+ // resize buffer size
if (m_bufSize == 0) m_bufSize = 100;
while (num >= m_bufSize) m_bufSize += 500;
}
}
- /* cleate elements */
+ // cleate elements
QString titleHTML, bodyHTML;
m_resStatus[ num ] = m_datInfo->getHTML(num, true, titleHTML, bodyHTML);
int readNum = m_datInfo->getReadNum();
- /* don't forget to reset abone here... */
+ // don't forget to reset abone here...
m_datInfo->resetAbone();
for (int i = 1; i <= readNum; i++) {
DOM::Element backupElement1, backupElement2, backupElement3;
int readNum = m_datInfo->getReadNum();
- /* remove <a href="#tosaigo"> and <BR> */
- backupElement1 = headerElement.removeChild(headerElement.lastChild()); /* BR */
- backupElement2 = headerElement.removeChild(headerElement.lastChild()); /* BR */
- backupElement3 = headerElement.removeChild(headerElement.lastChild()); /* "#tosaigo" */
+ // remove <a href="#tosaigo"> and <BR>
+ backupElement1 = headerElement.removeChild(headerElement.lastChild()); // BR
+ backupElement2 = headerElement.removeChild(headerElement.lastChild()); // BR
+ backupElement3 = headerElement.removeChild(headerElement.lastChild()); // "#tosaigo"
- DOM::Node node = headerElement.firstChild(); /* node is now "#kokomade_yonda" */
- node = node.nextSibling(); /* " " */
+ DOM::Node node = headerElement.firstChild(); // node is now "#kokomade_yonda"
+ node = node.nextSibling(); // " "
node = node.nextSibling();
- /* '1-', '101-' などのリンクを作成 */
+ // '1-', '101-' などのリンクを作成
for (int num = 1; num < readNum ; num += 100) {
if (node == 0) {
QString href = QString("#%1").arg(num);
}
}
- /* restore <a href="#tosaigo"> and <BR> */
- headerElement.appendChild(backupElement3); /* "#tosaigo" */
- headerElement.appendChild(backupElement2); /* BR */
- headerElement.appendChild(backupElement1); /* BR */
+ // restore <a href="#tosaigo"> and <BR>
+ headerElement.appendChild(backupElement3); // "#tosaigo"
+ headerElement.appendChild(backupElement2); // BR
+ headerElement.appendChild(backupElement1); // BR
}
/*
DOM::Element backupElement;
int readNum = m_datInfo->getReadNum();
- backupElement = footerElement.removeChild(footerElement.lastChild()); /* "#tosaigo" */
+ backupElement = footerElement.removeChild(footerElement.lastChild()); // "#tosaigo"
- DOM::Node node = footerElement.firstChild(); /* node is now "#kokomade_yonda" */
- node = node.nextSibling(); /* " " */
+ DOM::Node node = footerElement.firstChild(); // node is now "#kokomade_yonda"
+ node = node.nextSibling(); // " "
node = node.nextSibling();
- /* '1-', '101-' などのリンクを作成 */
+ // '1-', '101-' などのリンクを作成
for (int num = 1; num < readNum ; num += 100) {
if (node == 0) {
QString href = QString("#%1").arg(num);
}
}
- footerElement.appendChild(backupElement); /* "#tosaigo" */
+ footerElement.appendChild(backupElement); // "#tosaigo"
}
/*
{
slotDeletePopup();
- /* delete DomTree */
+ // delete DomTree
delete m_domtree;
m_domtree = 0;
DatManager datManager(m_datUrl);
- /* update ViewPos */
+ // update ViewPos
if (m_mode == HTMLPART_MODE_MAINPART && !m_updatedKokoyon
&& !m_datUrl.isEmpty()) {
int readNum = datManager.getReadNum();
}
m_updatedKokoyon = false;
- /* clear variables */
+ // clear variables
m_anchorStack.clear();
m_centerNum = 0;
m_jumpNumAfterLoading = 0;
findTextInit();
- if (!m_datUrl.isEmpty()) { /* This part is opened. */
- /* This part is on the main thread view. */
+ if (!m_datUrl.isEmpty()) { // This part is opened.
+ // This part is on the main thread view.
if (m_mode == HTMLPART_MODE_MAINPART) {
- /* tell Thread class that "thread is closed" */
+ // tell Thread class that "thread is closed"
datManager.setMainThreadOpened(false);
- /* emit "deactivated all thread view" SIGNAL */
+ // emit "deactivated all thread view" SIGNAL
KUrl nullUrl("");
ViewMediator::getInstance()->changeWriteTab(nullUrl);
- /* update subject tab. */
+ // update subject tab.
}
}
m_mode = mode;
if (m_mode == HTMLPART_MODE_MAINPART) {
- /* This part is on the main thread view. */
+ // This part is on the main thread view.
DatManager datManager(m_datUrl);
- /* create DatInfo explicitly to open new thread. */
- /* Usually, DatInfo is NOT created if ReadNum == 0.*/
- /* See also DatManager::createDatInfo() and */
- /* DatManager::getDatInfo(). */
+ // create DatInfo explicitly to open new thread.
+ // Usually, DatInfo is NOT created if ReadNum == 0.
+ // See also DatManager::createDatInfo() and
+ // DatManager::getDatInfo().
datManager.createDatInfo();
- /* tell Thread class that "thread is opened" */
+ // tell Thread class that "thread is opened"
datManager.setMainThreadOpened(true);
- /* reset abone */
+ // reset abone
datManager.resetAbone();
}
- /* create HTML Document */
+ // create HTML Document
createHTMLDocument();
- /* create DOM manager */
+ // create DOM manager
if (m_mode == HTMLPART_MODE_MAINPART) {
m_domtree = new DomTree(htmlDocument(), m_datUrl);
}
/* private */
void HTMLPart::connectSignals()
{
- /* popup */
+ // popup
connect(this, SIGNAL(onURL(const QString&)), SLOT(slotOnUrl(const QString&)));
connect(view(), SIGNAL(leave()), SLOT(slotLeave()));
/* private */
void HTMLPart::createHTMLDocument()
{
- /* style */
+ // style
QString style = QString("body { font-size: %1pt; font-family: \"%2\"; color: %3; background-color: %4; }")
.arg(GlobalConfig::threadFont().pointSize())
.arg(GlobalConfig::threadFont().family())
setJScriptEnabled(false);
setJavaEnabled(false);
- /* Use dummy URL here, and protocol should be "file:".
- If protocol is "http:", local image files are not shown
- (for security reasons ?).
- */
+ // Use dummy URL here, and protocol should be "file:".
+ // If protocol is "http:", local image files are not shown
+ // (for security reasons?).
begin(KUrl("file:/dummy.htm"));
write(text);
end();
return ;
}
- /* show clock cursor */
+ // show clock cursor
if (clock) {
QCursor qc; qc.setShape(Qt::WaitCursor);
QApplication::setOverrideCursor(qc);
}
- /* show header, footer, and kokomadeyonda, etc. */
+ // show header, footer, and kokomadeyonda, etc.
if (showHeaderEtc) {
m_domtree->appendKokoyon();
m_domtree->appendFooterAndHeader();
}
- /* change color of number of the res which is responsed. */
+ // change color of number of the res which is responsed.
if (m_mode == HTMLPART_MODE_MAINPART) {
if (GlobalConfig::checkResponsed()) {
}
}
- /* update display */
+ // update display
htmlDocument().applyChanges();
view()->layout();
view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
view()->setFocus();
- /* restore cursor */
+ // restore cursor
if (clock) {
QApplication::restoreOverrideCursor();
}
{
if (!m_domtree) return false;
if (m_mode != HTMLPART_MODE_MAINPART) {
- /* If this is not MainPart, then open MainPart. */
+ // If this is not MainPart, then open MainPart.
ViewMediator::getInstance()->openUrl(m_datUrl);
return false;
}
if (m_centerNum == 0) m_centerNum = m_domtree->getBottomResNumber();
m_jumpNumAfterLoading = jumpNum;
- /* DatManager will call back slotReceiveData and slotFinishLoad. */
+ // DatManager will call back slotReceiveData and slotFinishLoad.
DatManager(m_datUrl).updateCache(this);
view() ->setFocus();
int readNum = DatManager(m_datUrl).getReadNum();
int bottom = m_domtree->getBottomResNumber();
- /* parsing */
+ // parsing
parseResponses(bottom + 1, readNum);
- /* rendering */
+ // rendering
if (m_firstReceive || bottom + delta < readNum) {
showResponses(bottom + 1, readNum);
updateScreen(true, false);
if (res > 1) {
- /* is target valid ? */
+ // is target valid?
if (!DatManager(m_datUrl).isResValid(res))
return false;
if (res == 1) ancstr = "header";
if (pushPosition) pushCurrentPosition();
- /* KHTMLPart::gotoAnchor() will fail if the thread is not shown. */
- /* So KHTMLPart::gotoAnchor() should be called via custom event. */
- /* See also HTMLPart::customEvent() */
+ // KHTMLPart::gotoAnchor() will fail if the thread is not shown.
+ // So KHTMLPart::gotoAnchor() should be called via custom event.
+ // See also HTMLPart::customEvent()
GotoAnchorEvent * e = new GotoAnchorEvent(ancstr);
QApplication::postEvent(this, e); // Qt will delete it when done
QRegExp regexp(query);
regexp.setCaseSensitivity(Qt::CaseInsensitive);
- /* init */
+ // init
if (m_findNode.isNull()) {
m_findNode = htmlDocument().body();
m_find_y = 0;
- /* move to the last child node */
+ // move to the last child node
if (reverse) {
while (!m_findNode.lastChild().isNull()) m_findNode = m_findNode.lastChild();
m_find_y = view() ->contentsHeight();
if (m_findNode.nodeType() == DOM::Node::TEXT_NODE
|| m_findNode.nodeType() == DOM::Node::CDATA_SECTION_NODE) {
- /* find the word in the current node */
+ // find the word in the current node
DOM::DOMString nodeText = m_findNode.nodeValue();
QString nodestr = nodeText.string();
if (reverse && m_findPos != -1) nodestr.resize(m_findPos);
if (reverse) m_findPos = nodestr.lastIndexOf(regexp, m_findPos);
else m_findPos = nodestr.indexOf(regexp, m_findPos + 1);
- /* scroll & select & return */
+ // scroll & select & return
if (m_findPos != -1) {
int matchLen = regexp.matchedLength();
}
}
- /*------------------------*/
+ //------------------------
m_findPos = -1;
DOM::Node next;
- /* move to the next node */
+ // move to the next node
if (!reverse) {
next = m_findNode.firstChild();
}
}
}
- /* revearse */
+ // revearse
else {
next = m_findNode.lastChild();
QString str;
- /* If selected Text is composed of only digits, then show res popup. */
+ // If selected Text is composed of only digits, then show res popup.
if (!m_pushctrl && showSelectedDigitPopup()) return ;
- /*-----------------------------------*/
- /* create menu items */
+ //-----------------------------------
+ // create menu items
KMenu popupMenu(view());
KMenu* backSubMenu = 0;
KMenu* markSubMenu = 0;
- /*------*/
- /* jump */
+ //------
+ // jump
KAction* homeLinkAct = 0;
KAction* kokoLinkAct = 0;
KAction* endLinkAct = 0;
/* protected */
void HTMLPart::khtmlMousePressEvent(khtml::MousePressEvent* e)
{
- emit mousePressed(); /* to ThreadView to focus this view. */
+ emit mousePressed(); // to ThreadView to focus this view.
KUrl kurl;
if (!e->url().string().isEmpty()) {
if (e->url() != 0) {
- if (e->url().string().at(0) == '#') { /* anchor */
+ if (e->url().string().at(0) == '#') { // anchor
kurl = m_datUrl;
kurl.setRef(e->url().string().mid(1)) ;
}
return ;
}
- /* popup menu */
+ // popup menu
if (m_pushrightbt) {
showPopupMenu(kurl);
m_pushctrl = m_pushmidbt = m_pushrightbt = false;
QString refstr;
KUrl datUrl = getDatUrl(urlin , refstr);
- /*--------------------*/
- /* Ctrl + right click */
+ //--------------------
+ // Ctrl + right click
if (m_pushctrl && m_pushrightbt) {
showPopupMenu(urlin);
return ;
}
- /*--------------------------------*/
- /* If this is not anchor, then */
- /* emit openURLRequest and return */
+ //--------------------------------
+ // If this is not anchor, then
+ // emit openURLRequest and return
if (datUrl.host() != m_datUrl.host() || datUrl.path() != m_datUrl.path()) {
- /* right click */
+ // right click
if (m_pushrightbt) {
- /* start multi-popup mode or show popup menu */
+ // start multi-popup mode or show popup menu
if (!startMultiPopup()) showPopupMenu(urlin);
return ;
}
- /* right click */
+ // right click
ViewMediator::getInstance()->openUrl(urlin);
return ;
if (refstr.isEmpty()) return ;
- /*---------------------------*/
- /* show popupmenu for #write */
+ //---------------------------
+ // show popupmenu for #write
if (refstr.left(5) == "write") {
showWritePopupMenu(refstr);
return ;
}
- /*----------------------------*/
- /* extract responses by ID */
+ //----------------------------
+ // extract responses by ID
if (refstr.left(5) == "idpop") {
showIdPopup(refstr);
return ;
}
- /*---------------------------*/
- /* show popupmenu for #bepop */
+ //---------------------------
+ // show popupmenu for #bepop
if (refstr.left(5) == "bepop") {
showBePopupMenu(refstr);
return ;
}
- /*-------------------------*/
- /* start multi-popup mdde */
+ //-------------------------
+ // start multi-popup mdde
if (m_pushrightbt && startMultiPopup()) return ;
- /*----------------------------*/
- /* next 100 ,before 100 ,etc. */
+ //----------------------------
+ // next 100 ,before 100 ,etc.
if (m_mode == HTMLPART_MODE_MAINPART) {
if (refstr.left(7) == "tosaigo") {
slotClickGotoFooter();
}
}
- /*-------------------------------*/
- /* open Kita Navi or goto anchor */
+ //-------------------------------
+ // open Kita Navi or goto anchor
int refNum, refNum2;
DatManager datManager(m_datUrl);
QString namestr = datManager.getPlainName(resNum);
- /* show res tree */
+ // show res tree
if (m_pushrightbt) {
int num;
QString htmlstr = datManager.getTreeByRes(resNum, num);
return ;
}
- /*---------------------*/
- /* create popup menu */
+ //---------------------
+ // create popup menu
QString plainStr;
KMenu popupMenu(view());
.replace("%2B", "+")
.replace("%2F", "/");
- /* popup */
+ // popup
if (m_pushrightbt) {
int num;
QString htmlstr = DatManager(m_datUrl).getHtmlById(strid, num);
hidePopup();
- /* emit signal to have parent hide this if this is popup . */
+ // emit signal to have parent hide this if this is popup.
if (m_mode == HTMLPART_MODE_POPUP && !isUnderMouse(0, 0)) {
emit hideChildPopup();
}
hidePopup();
- /* emit signal to have parent hide this if this is popup . */
+ // emit signal to have parent hide this if this is popup.
if (m_mode == HTMLPART_MODE_POPUP && !isUnderMouse(mrg, 0)) {
emit hideChildPopup();
}
hidePopup();
- /* emit signal to have parent hide this if this is popup . */
+ // emit signal to have parent hide this if this is popup.
if (m_mode == HTMLPART_MODE_POPUP && !isUnderMouse(0, mrg)) {
emit hideChildPopup();
}
{
hidePopup();
- /* emit signal to have parent hide this if this is popup . */
+ // emit signal to have parent hide this if this is popup.
if (m_mode == HTMLPART_MODE_POPUP && !isUnderMouse(0, 0)) {
emit hideChildPopup();
}
/* This slot is called when mouse moves onto the URL */ /* private slot */
void HTMLPart::slotOnUrl(const QString& url)
{
- /* config */
+ // config
- const int maxpopup = 10; /* max number of responses shown in the popup window */
+ const int maxpopup = 10; // max number of responses shown in the popup window
- /*----------------------------*/
+ //----------------------------
if (isMultiPopupMode()) return ;
if (url.isEmpty()) return ;
if (url.left(7) == "mailto:") return ;
- /* Is Kita active now ? */
+ // Is Kita active now?
if(ViewMediator::getInstance()->isActive() == false) return;
- /* get reference */
+ // get reference
QString refstr;
KUrl datUrl = m_datUrl;
if (url.at(0) == '#') {
}
DatManager datManager(m_datUrl);
- /*------------------------*/
- /* id popup */
+ //------------------------
+ // id popup
if (url.left(6) == "#idpop") {
int num = datManager.getNumById(url.mid(6));
}
- /*------------------------*/
- /* show reffered num */
+ //------------------------
+ // show reffered num
if (refstr.left(5) == "write") {
int no = refstr.mid(5).toInt();
}
- /*------------------------*/
- /* abone */
+ //------------------------
+ // abone
if (url.left(6) == "#abone") {
int no = url.mid(6).toInt();
return ;
}
- /*-------------------------*/
- /* popup for anchor */
+ //-------------------------
+ // popup for anchor
QString innerHTML;
int refNum;
int refNum2;
int i = refstr.indexOf("-");
- if (i != -1) { /* >>refNum-refNum2 */
+ if (i != -1) { // >>refNum-refNum2
refNum = refstr.left(i).toInt();
refNum2 = refstr.mid(i + 1).toInt();
if (refNum2 - refNum > maxpopup - 1) refNum2 = refNum + maxpopup - 1;
}
- } else { /* >>refNum */
+ } else { // >>refNum
refNum = refstr.toInt();
refNum2 = refNum;
}
DatManager localDatManager(datUrl);
- /* another thread ? */
+ // another thread?
if (datUrl.host() != m_datUrl.host() || datUrl.path() != m_datUrl.path()) {
- /* get board name */
+ // get board name
BoardDatabase db(datUrl);
QString boardName = db.boardName();
if (!boardName.isEmpty()) innerHTML += '[' + boardName + "] ";
- /* If idx file of datURL is not read, thread name cannot be obtained.
- so, create DatInfo if cache exists, and read idx file in DatInfo::DatInfo(). */
+ // If idx file of datURL is not read, thread name cannot be obtained.
+ // so, create DatInfo if cache exists, and read idx file in DatInfo::DatInfo().
localDatManager.getDatInfoPointer();
- /* get thread Name */
+ // get thread Name
QString subName = localDatManager.threadName();
if (!subName.isEmpty()) innerHTML += subName + "<br><br>";
if (!refNum) refNum = refNum2 = 1;
}
- /* get HTML and show it */
+ // get HTML and show it
if (!refNum) return ;
innerHTML += localDatManager.getHtml(refNum, refNum2);
/* protected */
void HTMLView::wheelEvent(QWheelEvent * e)
{
- if (e->delta() < 0) { /* scroll down */
+ if (e->delta() < 0) { // scroll down
if (emitPushDown()) return ;
}
int y = contentsY();
if (y >= contentsHeight() - visibleHeight()) {
- emit pushDown(); /* to HTMLPart in order to call slotClickTugi100 */
+ emit pushDown(); // to HTMLPart in order to call slotClickTugi100
return true;
}
setupActions();
if (parent) {
- /* setup part manager */
+ // setup part manager
m_manager = new KParts::PartManager(parent, this);
m_manager->addManagedTopLevelWidget(parent);
} else {
TabWidgetBase::~TabWidgetBase()
{
- /* remove parts */
+ // remove parts
if (m_manager && !(m_manager->parts().isEmpty())) {
KParts::Part * part;
while ((part = m_manager->parts().first()) != 0) {
delete m_manager;
m_manager = 0;
- /* remove widgets which don't belong to parts */
+ // remove widgets which don't belong to parts
QWidget* view = currentWidget();
while (count() > 0 && view) {
removePage(view);
switch (m_bbstype) {
case Board_2ch:
- case Board_MachiBBS: /* Machi BBS's data is already parsed as 2ch dat. */
+ case Board_MachiBBS: // Machi BBS's data is already parsed as 2ch dat.
{
QString tmpData = K2ch().datToUnicode(orgData);
break;
default:
- /* convert data stream into 2ch dat.
- and emit receiveData SIGNAL. */
+ // convert data stream into 2ch dat.
+ // and emit receiveData SIGNAL.
emitDatLineList(orgData);
break;
}
QDataStream out(&file);
out << m_threadData;
}
- m_threadData.clear(); /* clear baffer */
+ m_threadData.clear(); // clear baffer
return ;
}
/* update cache file */ /* public */
bool Access::getupdate(int readNum)
{
- /* init */
+ // init
m_readNum = readNum;
m_threadData.clear();
m_firstReceive = false;
m_invalidDataReceived = false;
m_lastLine.clear();
- /* set URL of data */
+ // set URL of data
QString getUrl;
switch (m_bbstype) {
case Board_JBBS:
getUrl = getThreadUrl(m_datUrl);
- getUrl.replace("read.cgi", "rawmode.cgi"); /* adhoc... */
+ getUrl.replace("read.cgi", "rawmode.cgi"); // adhoc...
if (m_readNum > 0)
getUrl += '/' + QString::number(m_readNum + 1) + '-';
break;
getUrl = m_datUrl.prettyUrl();
}
- /* set UserAgent */
+ // set UserAgent
const QString useragent = QString("Monazilla/1.00 (Kita/%1)").arg(VERSION);
KIO::SlaveConfig::self() ->setConfigData("http",
KUrl(getUrl).host(),
"UserAgent", useragent);
- /* create new job */
+ // create new job
KIO::TransferJob* job
= KIO::get(getUrl, KIO::Reload, KIO::HideProgressInfo);
m_currentJob = job;
// use 'HTTP-Headers' metadata.
job->addMetaData("PropagateHttpHeader", "true");
- /* resume */
+ // resume
if (m_bbstype != Board_MachiBBS
&& m_bbstype != Board_JBBS
&& m_dataSize > 0) {
- m_firstReceive = true; /* remove first char (i.e. \n). see also slotReceiveThreadData() */
+ m_firstReceive = true; // remove first char (i.e. \n). see also slotReceiveThreadData()
job->addMetaData("resume", QString::number(m_dataSize - 1));
job->addMetaData("AllowCompressedPage", "false");
}
return ;
}
- /* check if received data is invalid (or broken). */
+ // check if received data is invalid (or broken).
if ((m_dataSize > 0 && responseCode() != 206)
|| (m_firstReceive && data_tmp[ 0 ] != '\n')
|| (m_dataSize == 0 && responseCode() != 200))
if (m_invalidDataReceived) return ;
- /* If this is the first call at resumption, remove LF(\n) at head. */
+ // If this is the first call at resumption, remove LF(\n) at head.
if (m_firstReceive) {
data_tmp = data_tmp.mid(1);
}
bool endIsLF = false;
if (dataStream.at(dataStream.length() - 1) == '\n') endIsLF = true;
- /* split the stream */
+ // split the stream
m_lastLine += dataStream;
lineList = m_lastLine.split('\n');
m_lastLine.clear();
- /* save the last line */
+ // save the last line
if (!endIsLF) {
QList<QByteArray>::iterator lastit = lineList.end();
}
}
- /* filtering */
+ // filtering
- /* convert lines into 2ch dat */
+ // convert lines into 2ch dat
int count = lineList.count();
for (int i = 0; i < count ; ++i) {
QByteArray ba;
int nextNum = m_readNum + 1;
- /* convert line */
+ // convert line
switch (m_bbstype) {
case Board_MachiBBS:
if (line2.isEmpty()) continue;
- /* add abone lines */
+ // add abone lines
const char aboneStr[] = "abone<><><>abone<>";
while (nextNum > m_readNum + 1) {
datLineList += aboneStr;
++m_readNum;
}
- /* save line */
+ // save line
if (m_bbstype == Board_MachiBBS) m_threadData += ba + '\n';
else m_threadData += lineList[ i ] + '\n';
++m_readNum;
}
}
- /* call DatInfo::slotReceiveData() */
+ // call DatInfo::slotReceiveData()
emit receiveData(datLineList);
}
void Access::stopJob()
{
- if (m_currentJob) m_currentJob->kill(); /* emit result signal */
+ if (m_currentJob) m_currentJob->kill(); // emit result signal
}
int Access::serverTime()
QStringList dateStrList = headerList.filter(regexp);
if (dateStrList.isEmpty() || regexp.indexIn(dateStrList[0]) == -1) {
// invalid response
- if (m_bbstype == Board_JBBS) return 200; /* adhoc... */
+ if (m_bbstype == Board_JBBS) return 200; // adhoc...
return 0;
} else {
return regexp.cap(1).toInt();
// use 'HTTP-Headers' metadata.
job->addMetaData("PropagateHttpHeader", "true");
- return QString(); /* dummy */
+ return QString(); // dummy
}
void OfflawAccess::slotThreadResult(KIO::Job* job)
: m_boardName(boardName), m_readIdx(false), m_rootPath(rootPath),
m_delimiter(delimiter), m_bbsPath(bbsPath), m_ext(ext), m_type(boardtype)
{
- /* set hostname and create URL of board */
+ // set hostname and create URL of board
setHostName(hostname);
- /* create default key */
+ // create default key
QStringList keyHosts(m_hostname);
createKeys(keyHosts);
- /* reset SETTING.TXT */
+ // reset SETTING.TXT
setSettingLoaded(false);
}
{
m_hostname = hostName;
- /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
+ // m_basePath = (hostname)/(rootPath)/(bbsPath)/
m_basePath = m_hostname + m_rootPath + m_bbsPath + '/';
switch (m_type) {
- case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+ case Board_MachiBBS: // m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath)
m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + "?BBS=" + m_bbsPath.mid(1);
break;
- /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+ // m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/
default:
m_cgiBasePath = m_hostname + m_rootPath + m_delimiter + m_bbsPath + '/';
break;
/* create keys of DB */ /* public */
void BoardData::createKeys(const QStringList& keyHostList)
{
- /* reset keys */
+ // reset keys
m_keyBasePathList.clear();
m_keyCgiBasePathList.clear();
m_keyHostList.clear();
m_keyHostList = keyHostList;
- /* m_basePath = (hostname)/(rootPath)/(bbsPath)/ */
+ // m_basePath = (hostname)/(rootPath)/(bbsPath)/
for (int i = 0; i < m_keyHostList.count(); ++i) {
if (m_keyHostList[ i ].length() > 0)
m_keyBasePathList += m_keyHostList[ i ] + m_rootPath + m_bbsPath + '/';
switch (m_type) {
- case Board_MachiBBS: /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath) */
+ case Board_MachiBBS: // m_cgiBasePath = (hostname)/(rootPath)/(delimiter)?BBS=(bbsPath)
for (int i = 0; i < m_keyHostList.count(); ++i)
m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter
+ "?BBS=" + m_bbsPath.mid(1);
break;
- /* m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/ */
+ // m_cgiBasePath = (hostname)/(rootPath)/(delimiter)/(bbsPath)/
default:
for (int i = 0; i < m_keyHostList.count(); ++i)
m_keyCgiBasePathList += m_keyHostList[ i ] + m_rootPath + m_delimiter + m_bbsPath + '/';
QString BoardDatabase::boardId()
{
BoardData * bdata = getBoardData();
- return (bdata == 0) ? QString() : bdata->bbsPath().mid(1); /* remove "/" */
+ return (bdata == 0) ? QString() : bdata->bbsPath().mid(1); // remove "/"
}
/* (hostname)/(rootPath)/(bbsPath)/subject.txt */ /* public */
threadList.clear();
oldLogList.clear();
- /* get all obtained threads list from cache */
+ // get all obtained threads list from cache
if (m_url.prettyUrl() == "http://virtual/obtained/") {
QStringList bbslist = allBoardUrlList();
- /* search all cache dirs */
+ // search all cache dirs
QString thread;
foreach (thread, bbslist) {
getCachedThreadList(thread, threadList);
return ;
}
- /*-------------------------*/
+ //-------------------------
BoardData* bdata = getBoardData();
if (bdata == 0) return ;
- /* download subject.txt */
+ // download subject.txt
if (online) {
- /* make directory */
+ // make directory
Cache cache(m_url);
QString cacheDir = cache.getDirPath();
if (!QDir::root().mkpath(cacheDir)) return;
KIO::NetAccess::download(subjectUrl(), subjectPath, 0);
}
- /* open and read subject.txt */
+ // open and read subject.txt
readSubjectTxt(bdata, threadList);
- /* get old logs */
+ // get old logs
if (oldLogs) {
QList<Thread*> tmpList;
QDir d(cacheDir);
if (d.exists()) {
- /* get all file names */
+ // get all file names
QString ext = getBoardData(url)->ext();
QString boardUrl = getBoardData(url)->basePath();
QStringList filter('*' + ext);
QString datUrl = boardUrl + "dat/" + file;
- /* read idx file */
+ // read idx file
Thread* thread = Thread::getByUrlNew(datUrl);
if (thread == 0) {
/* open subject.txt and get list of Thread classes */ /* private */
bool BoardDatabase::readSubjectTxt(BoardData* bdata, QList<Thread*>& threadList)
{
- /* get all names of cached files to read idx. */
+ // get all names of cached files to read idx.
QStringList cacheList;
if (!bdata->readIdx()) {
Cache cache(m_url);
}
}
- /* open subject.txt */
+ // open subject.txt
Cache cache(m_url);
QString subjectPath = cache.getSubjectPath();
QIODevice * device = KFilterDev::deviceForFile(subjectPath, "application/x-gzip");
QString subject = regexp.cap(2);
QString num = regexp.cap(3);
- /* get pointer of Thread class */
+ // get pointer of Thread class
QString datUrl = boardUrl() + "dat/" + fname;
Thread* thread = Thread::getByUrl(datUrl);
ThreadIndex threadIndex(datUrl);
threadList.append(thread);
}
- /* set thread name */
+ // set thread name
thread->setThreadName(subject);
- /* load index file */
+ // load index file
if (!bdata->readIdx()) {
if (cacheList.contains(fname)) {
}
}
- /* update res num */
+ // update res num
int newNum = num.toInt();
- if (thread->readNum()) { /* cache exists */
+ if (thread->readNum()) { // cache exists
int oldNum = thread->resNum();
if (newNum > oldNum) {
}
device->close();
- bdata->setReadIdx(true); /* never read idx files again */
+ bdata->setReadIdx(true); // never read idx files again
return true;
}
if (type == Board_Unknown) return Board_recordFailed;
- /* check if the board is recorded or moved. */
+ // check if the board is recorded or moved.
BoardData *data;
foreach (data, m_boardDataList) {
&& data->bbsPath() == bbsPath) {
if (data->hostName() == hostname
- && data->rootPath() == rootPath) { /* recorded */
+ && data->rootPath() == rootPath) { // recorded
return Board_recordRecorded;
- } else { /* moved */
+ } else { // moved
oldUrl = data->basePath();
return Board_recordMoved;
}
}
}
- /* test only */
+ // test only
if (test)
return Board_recordNew;
- /* record new board */
+ // record new board
BoardData* bdata = new BoardData(boardName, hostname, rootPath, delimiter, bbsPath, ext, type);
m_boardDataList.append(bdata);
bbsPath.clear();
ext.clear();
- /* decide type */
+ // decide type
if (type == Board_Unknown) {
if (m_url.host().contains("machi.to"))
type = Board_2ch;
}
- /* parse */
+ // parse
switch (type) {
- case Board_MachiBBS: /* MACHI : http:// *.machi.to/(bbsPath)/ */
+ case Board_MachiBBS: // MACHI : http:// *.machi.to/(bbsPath)/
delimiter = "/bbs/read.pl";
bbsPath = m_url.fileName();
ext = ".cgi";
break;
- case Board_JBBS: /* JBBS : http://jbbs.livedoor.jp/(bbsPath)/ */
+ case Board_JBBS: // JBBS : http://jbbs.livedoor.jp/(bbsPath)/
delimiter = "/bbs/read.cgi";
bbsPath = m_url.prettyUrl().remove(hostname);
ext = ".cgi";
break;
- case Board_FlashCGI: /* test for Flash CGI/Mini Thread */
+ case Board_FlashCGI: // test for Flash CGI/Mini Thread
delimiter = "/test/read.cgi";
bbsPath = m_url.fileName();
ext = ".dat";
break;
- default: /* 2ch : http://(hostname)/(rootPath)/(bbsPath)/ */
+ default: // 2ch : http://(hostname)/(rootPath)/(bbsPath)/
delimiter = "/test/read.cgi";
bbsPath = m_url.fileName();
break;
}
- /* For example, if bbsPath = "linux/", then m_bbsPath = "/linux" */
+ // For example, if bbsPath = "linux/", then m_bbsPath = "/linux"
const QRegExp exp("/$");
rootPath.remove(exp);
bbsPath.remove(exp);
return 0;
QString urlstr = url.prettyUrl();
- /* cache */
+ // cache
if (m_previousBoardData != 0 && m_previousBoardUrl == urlstr)
return m_previousBoardData;
if (urlstr.contains(data->keyBasePathList()[i])
|| urlstr.contains(data->keyCgiBasePathList()[i])) {
- /* cache */
+ // cache
m_previousBoardData = data;
m_previousBoardUrl = urlstr;
if (oldUrl == newUrl) return false;
- /* Is oldURL recorded? */
+ // Is oldURL recorded?
BoardData* bdata = getBoardData(oldUrl);
if (bdata == 0) {
- /* Is newURL recorded? */
+ // Is newURL recorded?
bdata = getBoardData(newUrl);
if (bdata == 0) return false;
}
- /*---------------------------*/
- /* update BoardData */
+ //---------------------------
+ // update BoardData
- /* get the path of old cache */
+ // get the path of old cache
bdata->setHostName(oldhost);
QStringList keyHosts = bdata->keyHostList();
keyHosts.removeOne(oldhost);
Cache cache(bdata->basePath());
QString oldCachePath = cache.getDirPath();
- /* update URL */
+ // update URL
bdata->setHostName(newhost);
- /* update keys */
- /* The order of keyHosts will be like this:
-
- newhost
- oldhost
- foohost1
- foohost2
-
- */
+ // update keys
+ // The order of keyHosts will be like this:
+ //
+ // newhost
+ // oldhost
+ // foohost1
+ // foohost2
+ //
keyHosts = bdata->keyHostList();
keyHosts.removeOne(oldhost);
keyHosts.prepend(oldhost);
keyHosts.prepend(newhost);
bdata->createKeys(keyHosts);
- /* reset BoardData */
+ // reset BoardData
bdata->setReadIdx(false);
bdata->setSettingLoaded(false);
- /*---------------------------*/
- /* move cache dir */
+ //---------------------------
+ // move cache dir
QDir qdir;
if (! qdir.exists(oldCachePath)) return true;
- /* mkdir new server dir */
+ // mkdir new server dir
Cache newCache(bdata->basePath());
QString newCachePath = Cache::baseDir() + newCache.serverDir();
QDir::root().mkpath(newCachePath);
- /* backup old dir */
+ // backup old dir
newCachePath += newCache.boardDir();
if (qdir.exists (newCachePath)) {
QString bkupPath = newCachePath;
- bkupPath.truncate(bkupPath.length() - 1); /* remove '/' */
+ bkupPath.truncate(bkupPath.length() - 1); // remove '/'
bkupPath +=
'.' + QString::number(QDateTime::currentDateTime().toTime_t());
qdir.rename(newCachePath, bkupPath);
}
- /* move cache dir */
+ // move cache dir
if (qdir.exists(oldCachePath)) {
qdir.rename(oldCachePath, newCachePath);
} else
QDir::root().mkpath(newCachePath);
- /* make old dir */
+ // make old dir
if (! qdir.exists(oldCachePath)) {
QDir::root().mkpath(oldCachePath);
- /* create BBS_MOVED */
+ // create BBS_MOVED
QString movedPath = oldCachePath + "/BBS_MOVED";
QFile file(movedPath);
if (file.open(QIODevice::WriteOnly)) {
file.close();
}
- /*---------------------------*/
- /* update BBSHISTRY */
+ //---------------------------
+ // update BBSHISTRY
Cache historyCache(bdata->basePath());
QFile file(historyCache.getBBSHistoryPath());
}
- /*---------------------------*/
- /* update other information */
+ //---------------------------
+ // update other information
FavoriteThreads::replace(oldUrl, newUrl);
Thread::replace(oldUrl, newUrl);
ThreadInfo::replace(oldUrl, newUrl);
QString Cache::serverDir() const
{
- /* Is board recorded ? */
+ // Is board recorded?
BoardDatabase db(m_url);
BoardData * bdata = db.getBoardData();
if (bdata == 0) return QString();
QString Cache::boardDir() const
{
- /* Is board recorded ? */
+ // Is board recorded?
BoardDatabase db(m_url);
BoardData * bdata = db.getBoardData();
if (bdata == 0) return QString();
QString refstr;
m_datUrl = getDatUrl(url, refstr);
m_threadIndex = ThreadIndex(m_datUrl);
- /* get the pointer of Thread class */
+ // get the pointer of Thread class
m_thread = Thread::getByUrlNew(m_datUrl);
if (m_thread == 0) {
- /* create Thread */
+ // create Thread
m_thread = Thread::getByUrl(m_datUrl);
if (m_thread == 0) return ;
- /* read idx file */
+ // read idx file
m_threadIndex.loadIndex(m_thread);
}
m_thread = Thread::getByUrl(m_datUrl);
- /* japanese strings */
+ // japanese strings
m_spacestr = QString::fromUtf8(KITAUTF8_ZENSPACE);
- m_framestr1 = QString::fromUtf8(KITAUTF8_FRAME1); /* | */
- m_framestr2 = QString::fromUtf8(KITAUTF8_FRAME2); /* |- */
- m_framestr3 = QString::fromUtf8(KITAUTF8_FRAME3); /* L */
+ m_framestr1 = QString::fromUtf8(KITAUTF8_FRAME1); // |
+ m_framestr2 = QString::fromUtf8(KITAUTF8_FRAME2); // |-
+ m_framestr3 = QString::fromUtf8(KITAUTF8_FRAME3); // L
- /* make directory */
+ // make directory
Cache cache(m_datUrl);
QString cacheDir = cache.getDirPath();
if (!QDir::root().mkpath(cacheDir)) return ;
initPrivate(
- true /* load cache */
+ true // load cache
);
}
/* Init. If loadCache = true, load data from cache. */ /* private */
void DatInfo::initPrivate(bool loadCache)
{
- /* stop & delete dat loader */
+ // stop & delete dat loader
deleteAccessJob();
- /* init variables */
+ // init variables
m_broken = false;
m_nowLoading = false;
m_lastLine.clear();
- /* clear ResDatVec */
+ // clear ResDatVec
m_resDatVec.clear();
increaseResDatVec(RESDAT_DEFAULTSIZE);
- /* reset Abone */
+ // reset Abone
resetAbonePrivate();
- /* create dat loader */
+ // create dat loader
m_access = new Access(m_datUrl);
connect(m_access, SIGNAL(receiveData(const QStringList&)),
if (!loadCache) return ;
- /* reset ReadNum before loading cache. */
- /* ReadNum & subject are updated by Access::getcache() */
+ // reset ReadNum before loading cache.
+ // ReadNum & subject are updated by Access::getcache()
m_thread->setReadNum(0);
- /* get dat from cahce */
- /* slotReceiveData() is called from Access::getcache() */
+ // get dat from cahce
+ // slotReceiveData() is called from Access::getcache()
m_access->getcache();
- /* save up-to-date thread information */
+ // save up-to-date thread information
m_threadIndex.saveIndex(m_thread);
}
if (rescode != 200 && rescode != 206) return ;
- /* copy lines to buffer */
+ // copy lines to buffer
int count = lineList.count();
for (int i = 0; i < count ; ++i)
copyOneLineToResDat(lineList[ i ]);
{
if (line.isEmpty()) return false;
- /* update ReadNum */
+ // update ReadNum
const int num = m_thread->readNum() + 1;
m_thread->setReadNum(num);
- /* If resdat vector is short, then resize the vector. */
+ // If resdat vector is short, then resize the vector.
while ((int) m_resDatVec.size() <= num)
increaseResDatVec(RESDAT_DELTA);
- /* reset ResDat */
+ // reset ResDat
RESDAT& resdat = m_resDatVec[ num ];
resetResDat(resdat);
resdat.num = num;
resdat.linestr = line;
- /* get subject */
+ // get subject
if (num == 1) parseDat(num);
- /* search all responses which are responsed by this line. */
+ // search all responses which are responsed by this line.
if (GlobalConfig::checkResponsed()) {
- if (parseDat(num) && !checkAbonePrivate(num)) { /* parse line here to get AncList */
+ if (parseDat(num) && !checkAbonePrivate(num)) { // parse line here to get AncList
const int maxRange = 10;
finished loading new dat */ /* private slot */
void DatInfo::slotFinishLoad()
{
- /* save thread information */
+ // save thread information
m_threadIndex.saveIndex(m_thread);
- /* re-try by offlaw.cgi */
+ // re-try by offlaw.cgi
DatManager datManager(m_datUrl);
if (m_thread->readNum() == 0 && m_access2 == 0
&& datManager.is2chThread()) {
return ;
}
}
- /* finish loading session & emit signal to the parent object */
+ // finish loading session & emit signal to the parent object
m_nowLoading = false;
emit finishLoad();
- /* disconnect signals */
+ // disconnect signals
disconnect(SIGNAL(receiveData()));
disconnect(SIGNAL(finishLoad()));
}
void DatInfo::stopLoading() const
{
- /* Don't lock the mutex here !!!
- It will cause deadlock , because
- Access::stopJob() calls HTMLPart::slotFinishLoad() back,
- then HTMLPart::slotFinishLoad() calls another functions in DatInfo. */
+ // Don't lock the mutex here !!!
+ // It will cause deadlock , because
+ // Access::stopJob() calls HTMLPart::slotFinishLoad() back,
+ // then HTMLPart::slotFinishLoad() calls another functions in DatInfo.
if (m_access == 0)
return;
if (!m_nowLoading)
if (!reverse) {
- /* collect responses that have anchor to rootnum */
+ // collect responses that have anchor to rootnum
for (int i = rootnum + 1; i <= m_thread->readNum(); i++) {
if (checkAbonePrivate(i)) continue;
if (checkRes(i, rootnum)) {
}
}
- } else { /* collect responses for which rootnum has anchors */
+ } else { // collect responses for which rootnum has anchors
AncList& anclist = m_resDatVec[ rootnum ].anclist;
for (AncList::iterator it = anclist.begin(); it != anclist.end(); ++it) {
}
}
- /* make HTML document */
+ // make HTML document
if (count) {
for (QStringList::iterator it = strlists.begin(); it != strlists.end(); ++it) {
QString tmpstr;
- if ((*it) == strlists.last()) tmpstr = m_framestr3; /* 'L' */
- else tmpstr = m_framestr2; /* '|-' */
+ if ((*it) == strlists.last()) tmpstr = m_framestr3; // 'L'
+ else tmpstr = m_framestr2; // '|-'
retstr += prestr + tmpstr + "<a href=\"#" + (*it) + "\">>>" + (*it) + "</a><br>";
- /* call myself recursively */
+ // call myself recursively
int tmpnum;
tmpstr = prestr;
- if ((*it) == strlists.last()) tmpstr += m_spacestr + m_spacestr + m_spacestr; /* " " */
- else tmpstr += m_framestr1 + m_spacestr; /* "| " */
+ if ((*it) == strlists.last()) tmpstr += m_spacestr + m_spacestr + m_spacestr; // " "
+ else tmpstr += m_framestr1 + m_spacestr; // "| "
retstr += getTreeByResCore((*it).toInt(), reverse, tmpnum, tmpstr);
count += tmpnum;
}
int rescode = m_access->responseCode();
bool invalid = m_access->invalidDataReceived();
- /* see also Access::slotReceiveThreadData() */
+ // see also Access::slotReceiveThreadData()
if (invalid && (rescode == 200 || rescode == 206)) return true;
- /* maybe "Dat Ochi" */
+ // maybe "Dat Ochi"
return false;
}
QRegExp regexp((*it));
regexp.setCaseSensitivity(Qt::CaseInsensitive);
- if (checkOr) { /* OR */
+ if (checkOr) { // OR
if (str_text.indexOf(regexp, 0) != -1) {
return true;
}
- } else { /* AND */
+ } else { // AND
if (str_text.indexOf(regexp, 0) == -1) return false;
}
}
int refNum = (*it).from;
int refNum2 = (*it).to;
- /* I don't want to enter loop... */
+ // I don't want to enter loop...
if (refNum >= num) continue;
if (refNum2 >= num) refNum2 = num - 1;
if (useTableTag) titleHtml += "<table class=\"res_title\"><tr>";
- /* res number */
+ // res number
if (useTableTag) titleHtml += "<td class=\"res_title_number\">";
titleHtml += "<a href=\"#write" + QString::number(resdat.num) + "\">";
titleHtml += QString::number(resdat.num);
titleHtml += "</a> ";
- /* name & mail address */
+ // name & mail address
if (useTableTag) titleHtml += "<td class=\"res_title_name\">";
titleHtml += "<b>" + QString::fromUtf8(KITAUTF8_NAME);
- /* show name with mail address */
+ // show name with mail address
if (showMailAddress) {
titleHtml += resdat.nameHTML;
if (!resdat.address.isEmpty()) titleHtml += " [" + resdat.address + ']';
- } else { /* don't show mail address */
+ } else { // don't show mail address
if (resdat.address.isEmpty()) {
titleHtml += "</b> ";
- /* date */
+ // date
if (useTableTag) titleHtml += "<td class=\"res_title_date\">";
titleHtml += QString::fromUtf8(KITAUTF8_COLON) + resdat.date;
if (useTableTag) titleHtml += "</td>";
- /* ID */
+ // ID
if (!resdat.id.isEmpty()) {
if (useTableTag) titleHtml += "<td class=\"res_title_id\">";
if (useTableTag) titleHtml += "</td>";
}
- /* BE */
+ // BE
if (!resdat.be.isEmpty()) {
if (useTableTag) titleHtml += "<td class=\"res_title_be\">";
if (useTableTag) titleHtml += "</td>";
}
- /* host */
+ // host
if (!resdat.host.isEmpty()) {
if (useTableTag) titleHtml += "<td class=\"res_title_host\">";
DatInfo* DatManager::getDatInfo(bool checkCached) const
{
- /* search */
- /* create and record instance */
+ // search
+ // create and record instance
return (m_searchDatInfo != 0)
? m_searchDatInfo : recordDatInfo(checkCached);
}
DatInfo* DatManager::searchDatInfo() const
{
if (m_datUrl.isEmpty())
- return 0; /* This url is not recorded in BoardManager. */
+ return 0; // This url is not recorded in BoardManager.
if (m_datInfoList.isEmpty())
return 0;
if (m_datUrl == datInfo->url()) {
- /* LRU */
+ // LRU
if (i) {
m_datInfoList.erase(it);
m_datInfoList.prepend(datInfo);
DatInfo* DatManager::recordDatInfo(bool checkCached) const
{
if (m_datUrl.isEmpty())
- return 0; /* This url is not recorded in BoardManager. */
+ return 0; // This url is not recorded in BoardManager.
- /* create DatInfo & read cached data */
+ // create DatInfo & read cached data
DatInfo* datInfo = new DatInfo(m_datUrl);
- /* Does cache exist ? */
- /* If cache does not exist, delete DatInfo here. */
+ // Does cache exist?
+ // If cache does not exist, delete DatInfo here.
if (checkCached && datInfo->getReadNum() == 0) {
delete datInfo;
return 0;
m_datInfoList.prepend(datInfo);
- /* delete the all old instances (LRU algorithm)*/
+ // delete the all old instances (LRU algorithm)
if (m_datInfoList.count() > DMANAGER_MAXQUEUE) {
for (int i = DMANAGER_MAXQUEUE; i < m_datInfoList.count(); i++) {
DatInfo* deleteInfo = m_datInfoList.at(i);
if (thread->readNum() == 0)
return false;
- /* init DatInfo */
+ // init DatInfo
if (m_searchDatInfo && !m_searchDatInfo->deleteCache()) {
return false;
}
- /* reset readNum & veiwPos */
+ // reset readNum & veiwPos
thread->setReadNum(0);
thread->setViewPos(0);
- /* delete cache */
+ // delete cache
Cache cache(m_datUrl);
QString cachePath = cache.getPath();
QString indexPath = cache.getIndexPath();
QFile::remove(indexPath);
QFile::remove(cachePath);
- /* delete log from "cache" */
+ // delete log from "cache"
ThreadInfo::removeThreadInfo(m_datUrl.prettyUrl());
return true;
}
if (thread != 0)
thread->setViewPos(num);
- /* save idx */
+ // save idx
ThreadIndex threadIndex(m_url);
threadIndex.setViewPos(num);
- /* save "cache" */
+ // save "cache"
ThreadInfo::setReadNum(m_datUrl.prettyUrl(), num);
}
QString ret;
int mib = m_writeCodec->mibEnum();
- (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */
+ (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; // kakikomu
(ret += "&FROM=") += encodeString(data.name(), mib);
(ret += "&mail=") += encodeString(data.mail(), mib);
(ret += "&MESSAGE=") += encodeString(data.body(), mib);
QString ret;
int mib = m_writeCodec->mibEnum();
- ret += "submit=%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */
+ ret += "submit=%8f%91%82%ab%8d%9e%82%de"; // kakikomu
ret += "&NAME=" + encodeString(data.name(), mib);
ret += "&MAIL=" + encodeString(data.mail(), mib);
ret += "&MESSAGE=" + encodeString(data.body(), mib).replace(';', "%3B");
int mib = m_writeCodec->mibEnum();
- ret += "submit=%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */
+ ret += "submit=%8f%91%82%ab%8d%9e%82%de"; // kakikomu
- /* from, mail, message, bbs */
+ // from, mail, message, bbs
ret += "&FROM=" + encodeString(data.name(), mib);
ret += "&mail=" + encodeString(data.mail(), mib);
ret += "&MESSAGE=" + encodeString(data.body(), mib);
ret += "&bbs=" + data.boardId();
ret += "&tepo=don";
- /* key */
+ // key
ret += "&key=" + data.threadId();
- /* time */
+ // time
ret += "&time=" + QString::number(data.serverTime());
- /* login */
+ // login
if (!data.sessionId().isEmpty()) {
ret += "&sid=" + data.sessionId();
}
int m_bbstype = db.type();
QString m_bbscgi;
- /* set path of bbs.cgi */
+ // set path of bbs.cgi
switch (m_bbstype) {
case Board_JBBS: {
if (url.isEmpty()) return QString();
- /* cache */
+ // cache
if (m_prevConvMode == mode && m_prevConvUrl == url.prettyUrl()) {
refstr = m_prevConvRefstr;
return m_prevConvNewUrl;
}
- /* Is board recorded ? */
+ // Is board recorded?
BoardDatabase db(url);
BoardData* bdata = db.getBoardData();
if (bdata == 0) return QString();
QString urlstr = url.prettyUrl();
- /* get thread & reference */
+ // get thread & reference
QString thread;
QString refBase;
if (urlstr.contains("/dat/")) {
- /* url = (hostname)/(rootPath)/(bbsPath)/dat/(thread_ID).(ext)#(refBase) */
+ // url = (hostname)/(rootPath)/(bbsPath)/dat/(thread_ID).(ext)#(refBase)
thread = url.fileName().remove(bdata->ext());
refBase = url.ref();
} else if (urlstr.contains(bdata->delimiter())) {
QString tmpstr;
switch (bdata->type()) {
- /* machi BBS */
- /* ex.) If url = http://kanto.machi.to/bbs/read.pl?BBS=kana&KEY=1096716679 ,
- then, thread = 1096716679 */
+ // machi BBS
+ // ex.) If url = http://kanto.machi.to/bbs/read.pl?BBS=kana&KEY=1096716679 ,
+ // then, thread = 1096716679
case Board_MachiBBS:
thread = url.queryItem("KEY");
refBase.clear();
break;
- /* url = (hostname)/(rootPath)/(delimiter)/(bbsPath)/(thread_ID)/(refBase) */
+ // url = (hostname)/(rootPath)/(delimiter)/(bbsPath)/(thread_ID)/(refBase)
default:
tmpstr = urlstr.section(bdata->delimiter() + bdata->bbsPath(), 1, 1);
thread = tmpstr.section('/', 1, 1);
else refstr = refBase;
}
- /* create new URL */
+ // create new URL
QString newUrl;
if (mode == URLMODE_DAT) newUrl = bdata->basePath() + "dat/" + thread + bdata->ext();
else {
}
}
- /* cache */
+ // cache
m_prevConvMode = mode;
m_prevConvUrl = url.prettyUrl();
m_prevConvNewUrl = newUrl;
*/
QString Kita::datToOfflaw(const KUrl& datUrl)
{
- /* TODO: not tested. */
+ // TODO: not tested.
KUrl url(datUrl);
QString root = url.host();
QRegExp regexp3("<dt>(\\d*) .*<font color=\"#......\"><b> (.*) </b></font> .* (..../../..).* (..:..:..) ID:([^<]*) <font size=.>\\[ ([^ ]*) \\]</font><br><dd>(.*)");
QRegExp regexp4("<dt>(\\d*) .*<a href=\"mailto:(.*)\"><b> (.*) </B></a> .* (..../../..).* (..:..:..) ID:([^<]*) <font size=.>\\[ ([^ ]*) \\]</font><br><dd>(.*)");
- /* abone */
+ // abone
QRegExp regexp5("<dt>(\\d*) .*<br><dd>.*");
host = regexp4.cap(7);
message = regexp4.cap(8);
- } else if (regexp5.indexIn(m_machiLine) != -1) { /* abone */
+ } else if (regexp5.indexIn(m_machiLine) != -1) { // abone
num = regexp5.cap(1).toInt();
m_machiLine.clear();
if (num == nextNum) return "abone<><><>abone<>";
else return QString();
- } else if (title_regexp.indexIn(m_machiLine) != -1) { /* get title */
+ } else if (title_regexp.indexIn(m_machiLine) != -1) { // get title
m_machiSubject = title_regexp.cap(1);
m_machiLine.clear();
if (num < nextNum) return QString();
- /* remove tag */
+ // remove tag
QRegExp rex("<[^<]*>");
name.remove(rex);
- /* remove week */
+ // remove week
rex = QRegExp("\\(.*\\)");
date.remove(rex);
QString id = list[ 6 ];
QString host = list[ 7 ];
- /* remove tag */
+ // remove tag
QRegExp rex("<[^<]*>");
name.remove(rex);
QString ret;
int mib = m_writeCodec->mibEnum();
- (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; /* kakikomu */
+ (ret += "submit=") += "%8f%91%82%ab%8d%9e%82%de"; // kakikomu
(ret += "&NAME=") += encodeString(data.name(), mib);
(ret += "&MAIL=") += encodeString(data.mail(), mib);
(ret += "&MESSAGE=") += encodeString(data.body(), mib);
case '<':
- /* " <br> " */
+ // " <br> "
if (chpt[ i + 1 ] == 'b' && chpt[ i + 2 ] == 'r' && chpt[ i + 3 ] == '>') {
unsigned int i2 = i - startPos;
- if (i > 0 && chpt[ i - 1 ] == ' ') i2--; /* remove space before <br> */
+ if (i > 0 && chpt[ i - 1 ] == ' ') i2--; // remove space before <br>
text += rawData.mid(startPos, i2) + '\n';
startPos = i + 4;
- if (chpt[ startPos ] == ' ') startPos++; /* remove space after <br> */
+ if (chpt[ startPos ] == ' ') startPos++; // remove space after <br>
i = startPos - 1;
}
- /*----------------------------------------*/
+ //----------------------------------------
- /* remove HTML tags <[^>]*> */
+ // remove HTML tags <[^>]*>
else {
if (i - startPos) text += rawData.mid(startPos, i - startPos);
break;
- /*----------------------------------*/
+ //----------------------------------
case '&':
- /* special char */
+ // special char
{
QString tmpstr;
tmpstr = parseSpecialChar(chpt + i, pos);
static bool isHYPHEN(unsigned short c)
{
- /* UTF-16 */
+ // UTF-16
if (c == '-'
|| (c >= 0x2010 && c <= 0x2015)
|| (c == 0x2212)
- || (c == 0xFF0D) /* UTF8: 0xEFBC8D */
+ || (c == 0xFF0D) // UTF8: 0xEFBC8D
) {
return true;
}
refNum[ 1 ] = 0;
pos = 0;
- /* check '>' twice */
+ // check '>' twice
for (int i = 0; i < 2; i++) {
if (cdat[ pos ].unicode() == UTF16_BRACKET) {
linkstr += cdat[ pos ];
pos++;
- } else if (cdat[ pos ] == '&' && cdat[ pos + 1 ] == 'g' /* > */
+ } else if (cdat[ pos ] == '&' && cdat[ pos + 1 ] == 'g' // >
&& cdat[ pos + 2 ] == 't' && cdat[ pos + 3 ] == ';') {
linkstr += '>';
pos += 4;
}
- /* check ',' */
+ // check ','
if (!pos) {
if (cdat[ pos ] == ',' || cdat[ pos ].unicode() == UTF16_COMMA) {
linkstr += ',';
}
}
- /* check '=' */
+ // check '='
if (!pos) {
if (cdat[ pos ] == '=' || cdat[ pos ].unicode() == UTF16_EQ) {
linkstr += '=';
}
}
- /* check digits */
+ // check digits
int hyphen = 0;
for (int i = 0 ; i < KITA_RESDIGIT + 1 && pos < length ; i++, pos++) {
unsigned int length = resdat.name.length();
resdat.nameHTML.clear();
- /* anchor */
+ // anchor
while (parseResAnchor(chpt + i, length - i, linkstr, refNum, pos)) {
linkurl = QString("#%1").arg(refNum[ 0 ]);
i += pos;
}
- /* non-digits strings */
+ // non-digits strings
if (i < length) {
resdat.nameHTML += "<span class=\"name_noaddr\">";
}
resdat.date = rawStr.left(pos);
- /* id */
+ // id
if (chpt[ pos ] == 'I' && chpt[ pos + 1 ] == 'D') {
pos += 3;
startpos = pos;
if (pos >= length) return ;
- /* be */
+ // be
if (chpt[ pos ] == 'B' && chpt[ pos + 1 ] == 'E') {
pos += 3;
startpos = pos;
if (pos >= length) return ;
- /* host */
+ // host
if (chpt[ pos ] == 'H' && chpt[ pos + 1 ] == 'O') {
pos += 5;
startpos = pos;
)
{
- /*-----------------------------*/
+ //-----------------------------
linkstr.clear();
linkurl.clear();
unsigned int pos;
unsigned int length = rawStr.length();
- /* parse anchor */
+ // parse anchor
if (!parseResAnchor(chpt + i, length - i, linkstr, refNum, pos)) {
i += pos - 1;
return false;
}
- /* create anchor */
+ // create anchor
resdat.bodyHTML += rawStr.mid(startPos, i - startPos);
linkurl = QString("#%1").arg(refNum[ 0 ]);
if (refNum[ 1 ]) linkurl += QString("-%1").arg(refNum[ 1 ]);
resdat.bodyHTML += linkstr;
resdat.bodyHTML += "</a>";
- /* add anchor to ancList */
+ // add anchor to ancList
ANCNUM anctmp;
if (refNum[ 1 ] < refNum[ 0 ]) refNum[ 1 ] = refNum[ 0 ];
anctmp.from = refNum[ 0 ];
bool ancChain = false;
- /* ancChain is chain for anchor. For examle, if anchor ">2"
- appeared, ancChain is set to true. Moreover, if next strings
- are "=5", anchor for 5 is also set. Thus, we can obtain anchors
- for strings ">2=5" as follows:
-
- <a href="#2">>2</a><a href="#5">=5</a>
- */
+ // ancChain is chain for anchor. For examle, if anchor ">2"
+ // appeared, ancChain is set to true. Moreover, if next strings
+ // are "=5", anchor for 5 is also set. Thus, we can obtain anchors
+ // for strings ">2=5" as follows:
+ //
+ // <a href="#2">>2</a><a href="#5">=5</a>
int offset = 0;
- if (chpt[ 0 ] == ' ') offset = 1; /* remove one space after <> */
+ if (chpt[ 0 ] == ' ') offset = 1; // remove one space after <>
for (unsigned int i = startPos = offset ; i < length ; i++) {
switch (chpt[ i ].unicode()) {
case '<':
- /* " <br> " */
+ // " <br> "
if (chpt[ i + 1 ] == 'b' && chpt[ i + 2 ] == 'r' && chpt[ i + 3 ] == '>') {
- /* reset anchor chain */
+ // reset anchor chain
ancChain = false;
unsigned int i2 = i - startPos;
- if (i > 0 && chpt[ i - 1 ] == ' ') i2--; /* remove space before <br> */
+ if (i > 0 && chpt[ i - 1 ] == ' ') i2--; // remove space before <br>
resdat.bodyHTML += rawStr.mid(startPos, i2);
resdat.bodyHTML += "<br>";
startPos = i + 4;
- if (chpt[ startPos ] == ' ') startPos++; /* remove space after <br> */
+ if (chpt[ startPos ] == ' ') startPos++; // remove space after <br>
i = startPos - 1;
}
- /*----------------------------------------*/
+ //----------------------------------------
- /* remove HTML tags <[^>]*> */
+ // remove HTML tags <[^>]*>
else {
if (i - startPos) resdat.bodyHTML += rawStr.mid(startPos, i - startPos);
break;
- /*----------------------------------------*/
+ //----------------------------------------
- case 'h': /* "http://" or "ttp://" or "tp:" */
+ case 'h': // "http://" or "ttp://" or "tp:"
case 't':
{
unsigned int pos = 0;
break;
- /*----------------------------------*/
+ //----------------------------------
case '&':
- /* > */
+ // >
if (chpt[ i + 1 ] == 'g' && chpt[ i + 2 ] == 't' && chpt[ i + 3 ] == ';')
ancChain = createResAnchor(rawStr, resdat, chpt, i, startPos);
break;
- /*----------------------------------------*/
+ //----------------------------------------
- /* unicode '>' */
+ // unicode '>'
case UTF16_BRACKET:
ancChain = createResAnchor(rawStr, resdat, chpt, i, startPos);
break;
- /*----------------------------------*/
+ //----------------------------------
default:
resdat.broken = false;
resdat.anclist.clear();
- /* search the staring positions of each section to split raw data. */
+ // search the staring positions of each section to split raw data.
const QChar *chpt = resdat.linestr.unicode();
unsigned int length = resdat.linestr.length();
unsigned int section = 0;
unsigned int sectionPos[ 5 ];
for (unsigned int i = 0 ; i < length ; i++) {
- /* sections are splitted by "<>" */
+ // sections are splitted by "<>"
if (chpt[ i ] == '<' && chpt[ i + 1 ] == '>') {
section++;
}
}
- /* broken data */
+ // broken data
if (section != 4) {
resdat.broken = true;
return true;
// qDebug("[%d] %d %d %d %d",section, sectionPos[1],sectionPos[2],sectionPos[3],sectionPos[4]);
- /* name */
+ // name
length = sectionPos[ 1 ] - 2 ;
parseName(resdat.linestr.mid(0, length), resdat);
- /* mail */
+ // mail
length = sectionPos[ 2 ] - 2 - sectionPos[ 1 ];
datToText(resdat.linestr.mid(sectionPos[ 1 ], length), resdat.address);
- /* date, ID, host */
+ // date, ID, host
length = sectionPos[ 3 ] - 2 - sectionPos[ 2 ];
parseDateId(resdat.linestr.mid(sectionPos[ 2 ], length), resdat);
- /* body */
+ // body
length = sectionPos[ 4 ] - 2 - sectionPos[ 3 ];
parseBody(resdat.linestr.mid(sectionPos[ 3 ], length), resdat);
- /* subject */
+ // subject
subject = resdat.linestr.mid(sectionPos[ 4 ]);
return true;
DatManager datManager(m_datUrl);
m_threadId = datManager.threadId();
m_serverTime = datManager.getServerTime();
- /* login */
+ // login
if (datManager.is2chThread() && Account::isLogged()) {
m_sessionId = KUrl::toPercentEncoding(Account::getSessionId());
}
void Thread::setThreadName(const QString& name)
{
QString threadName = name;
- /* remove space */
+ // remove space
QRegExp qrx(" +$");
threadName.remove(qrx);
- /* unescape */
+ // unescape
threadName.replace("<", "<").replace(">", ">").replace("&", "&");
m_threadName = threadName;
void ThreadIndex::loadIndex(Thread* thread, bool checkCached) const
{
KConfig config(m_indexPath);
- /* load read number */
+ // load read number
int readNum = getReadNumPrivate(config, checkCached);
- if (readNum == 0) return ; /* cache does not exist. */
+ if (readNum == 0) return ; // cache does not exist.
thread->setReadNum(readNum);
- /* load thread name */
+ // load thread name
QString subject = getSubjectPrivate(config);
if (subject.isEmpty() && !thread->threadName().isEmpty()) {
subject = thread->threadName();
if (subject.isEmpty()) thread->setThreadName("?");
else thread->setThreadName(subject);
- /* load res number */
+ // load res number
thread->setResNum(getResNumPrivate(config));
- /* load view pos */
+ // load view pos
thread->setViewPos(getViewPosPrivate(config));
if (thread->viewPos() > thread->readNum())
thread->setReadNum(thread->viewPos());
- /* load mark */
+ // load mark
thread->setMarkList(getMarkListPrivate(config));
}
/* save thread information */ /* public */
void ThreadIndex::saveIndex(const Thread* thread)
{
- /* If readNum == 0, delete idx file */
+ // If readNum == 0, delete idx file
if (thread->readNum() == 0) {
QFile::remove(m_indexPath);
}
KConfig config(m_indexPath);
- /* save thread name */
+ // save thread name
setSubjectPrivate(config, thread->threadName());
- /* save res number */
+ // save res number
setResNumPrivate(config, thread->resNum());
- /* save read number */
+ // save read number
setReadNumPrivate(config, thread->readNum());
- /* save view pos */
+ // save view pos
setViewPosPrivate(config, thread->viewPos());
- /* save mark */
+ // save mark
setMarkListPrivate(config, thread->markList());
- /* save "cache" */
+ // save "cache"
KUrl datUrl = getDatUrl(m_url);
int num = (thread->viewPos() ? thread->viewPos() : thread->readNum());
ThreadInfo::setReadNum(datUrl.prettyUrl(), num);
{
int resNum = config.group("").readEntry("ResNum", 0);
- /* use obsoleted "cache" file */
+ // use obsoleted "cache" file
if (!resNum) {
KUrl datUrl = getDatUrl(m_url);
resNum = ThreadInfo::readNum(datUrl.prettyUrl());
/* private */
int ThreadIndex::getReadNumPrivate(KConfig& config, bool checkCached) const
{
- /* If cache does not exist, return 0 */
+ // If cache does not exist, return 0
if (checkCached) {
Cache cache(m_url);
QString path = cache.getPath();
if (!readNum) {
- /* use ViewPos instead of ReadNum. */
+ // use ViewPos instead of ReadNum.
readNum = config.group("").readEntry("ViewPos", 0);
- /* use obsoleted "cache" file */
+ // use obsoleted "cache" file
if (!readNum) {
KUrl datUrl = getDatUrl(m_url);
readNum = ThreadInfo::readNum(datUrl.prettyUrl());
setCentralWidget(mainWidget);
- /* write dock */
+ // write dock
m_writeTab = new WriteTabWidget(0);
ViewMediator::getInstance()->setWriteTabWidget(m_writeTab);
}
QRect qr = curnode.getRect();
int tmpwd = qr.right() - qr.left();
- /*----------------------------------*/
+ //----------------------------------
if (curnode.nodeType() == DOM::Node::TEXT_NODE) {
if (xx == 0) xx = qr.left();
width += tmpwd;
}
- /*----------------------------------*/
+ //----------------------------------
else if (curnode.nodeName().string() == "div") {
if (leftmrg == 0) leftmrg = qr.left();
xx = 0;
}
- /*----------------------------------*/
+ //----------------------------------
else if (curnode.nodeName().string() == "br") {
width = 0;
}
- /*----------------------------------*/
+ //----------------------------------
if (leftmrg + xx + width > maxwidth) maxwidth = leftmrg + xx + width;
if (qr.bottom() > maxheight) maxheight = qr.bottom();
- /* move to the next node */
+ // move to the next node
DOM::Node next = curnode.firstChild();
if (next.isNull()) next = curnode.nextSibling();
POS_RightDown
};
- /* config */
+ // config
const int mrg = 16;
- /*----------------------------*/
+ //----------------------------
if (!m_htmlPart) return ;
/* move mouse pointer above the popup frame */ /* public */
void ResPopup::moveMouseAbove()
{
- /* config */
+ // config
const int mrg = 10;
- /*-------------------------------*/
+ //-------------------------------
QPoint pos = QCursor::pos();
int cx = pos.x(), cy = pos.y();
setupActions();
- /* default view */
+ // default view
createView(i18nc("@title:tab", "Thread"));
}
setCurrentWidget(view);
if (view->threadUrl().isEmpty()) {
- /* Show on the default view */
+ // Show on the default view
view->showThread(datUrl, jumpNum);
} else {
- /* The view is already shown */
- /* TODO: jump to jumpNum after reloading */
+ // The view is already shown
+ // TODO: jump to jumpNum after reloading
view->slotReloadButton(jumpNum);
}
if (view->getViewMode() == VIEWMODE_MAINVIEW) {
if (view->datUrl() == datUrl
- || view->datUrl().isEmpty() /* default view */
+ || view->datUrl().isEmpty() // default view
) return view;
}
}
ViewMediator::getInstance()->setMainStatus(QString());
ViewMediator::getInstance()->setMainUrlLine(KUrl());
- /* default view */
+ // default view
ThreadView * threadView = createView(i18nc("@title:tab", "Thread"));
if (threadView) {
popup.addAction(act);
}
popup.exec(e->globalPos());
-/* KActionCollection * collection = client->actionCollection();
- KAction* action;
- action = new KAction(i18n("goback anchor"), SmallIcon("idea"), KShortcut(), m_threadPart, SLOT(gobackAnchor()), collection, "goback_anchor");
- emit popupMenu(client, global, url, mimeType, mode);*/ // TODO
+// KActionCollection * collection = client->actionCollection();
+// KAction* action;
+// action = new KAction(i18n("goback anchor"), SmallIcon("idea"), KShortcut(), m_threadPart, SLOT(gobackAnchor()), collection, "goback_anchor");
+// emit popupMenu(client, global, url, mimeType, mode); // TODO
}
{
m_parent = parent;
- /* copied from Base class */
+ // copied from Base class
setFocusPolicy(Qt::ClickFocus);
threadViewBaseLayout = new QVBoxLayout(this);
threadViewBaseLayout->addWidget(threadFrame);
resize(QSize(870, 480).expandedTo(minimumSizeHint()));
setAttribute(Qt::WA_WState_Polished);
- /* copy end */
+ // copy end
m_threadPart = new HTMLPart(threadFrame);
QHBoxLayout* aLayout = new QHBoxLayout(threadFrame);
/*-------*/
void ThreadView::setup(const KUrl& datUrl, int mode)
{
- /* config. */
+ // config.
- /*---------------------------------------*/
- /* setup */
+ //---------------------------------------
+ // setup
m_datUrl = getDatUrl(datUrl);
- /* setup HTMLPart */
+ // setup HTMLPart
int partMode = HTMLPART_MODE_MAINPART;
m_threadPart->setup(partMode, m_datUrl);
- /* mode. Mode is defined in threadview.h */
+ // mode. Mode is defined in threadview.h
m_viewmode = mode;
- /* reset search direction */
+ // reset search direction
m_revsearch = false;
}
/*--------------------------------------------------------*/
void ThreadView::showThread(const KUrl& datUrl, int num)
{
- /* If this widget is not parent, then do nothing. */
+ // If this widget is not parent, then do nothing.
if (m_viewmode != VIEWMODE_MAINVIEW) return ;
if (num == 0) num = DatManager(datUrl).getViewPos();
topLevelWidget() ->raise();
activateWindow();
- /* setup */
+ // setup
setup(datUrl, VIEWMODE_MAINVIEW);
- /* get log from cahce */
+ // get log from cahce
m_rescode = 200;
if (!m_threadPart->load(num)) showStatusBar("");
- /* update data */
+ // update data
slotUpdateInfo();
slotReloadButton();
}
/* stop loading the thread */ /* public slot */
void ThreadView::slotStopLoading()
{
- /* hide popup */
+ // hide popup
if (m_threadPart->isPopupVisible()) {
m_threadPart->slotDeletePopup();
return ;
}
- /* unforcus search combo */
+ // unforcus search combo
if (searchCombo->hasFocus()) {
setFocus();
return ;
if (broken)
info += " " + i18nc("@info:status", "This thread is broken.");
- /* show status bar,caption, url */
+ // show status bar,caption, url
infostr = datManager.threadName() +
QString(" [Total: %1 New: %2] %3 k").arg(resNum)
.arg(resNum - viewPos).arg(datSize / 1024)
m_rescode = datManager.getResponseCode();
m_serverTime = datManager.getServerTime();
- /* uptate information */
+ // uptate information
BoardDatabase db(m_datUrl);
setSubjectLabel(db.boardName(), datManager.threadName() + QString(" (%1)")
.arg(datManager.getReadNum()), db.boardUrl());
showStatusBar("");
- emit showThreadCompleted(); /* to ThreadPart */
+ emit showThreadCompleted(); // to ThreadPart
}
/*------------------------*/ /* private slots */
void ThreadView::slotSearchButton()
{
- if (m_datUrl.isEmpty()) return ; /* Nothing is shown on the screen.*/
+ if (m_datUrl.isEmpty()) return ; // Nothing is shown on the screen.
QString str = searchCombo->currentText();
if (str.at(0) == ':') {
- /* show res popup */
+ // show res popup
if (str.at(1) == 'p') {
int refNum = str.mid(2).toInt();
QPoint pos = mapToGlobal(searchCombo->pos());
m_threadPart->slotShowResPopup(pos , refNum, refNum);
return ;
}
- /* find by find dialog */
+ // find by find dialog
else if (str.at(1) == 'f') {
KAction * act = static_cast< KAction* >(m_threadPart->action("find"));
if (act) act->trigger();
return ;
}
- /* jump */
+ // jump
QString anc = str.mid(1);
m_threadPart->gotoAnchor(anc, false);
searchCombo->setFocus();
/* private */
void ThreadView::slotSearchPrivate(bool rev)
{
- if (m_datUrl.isEmpty()) return ; /* Nothing is shown on the screen.*/
+ if (m_datUrl.isEmpty()) return ; // Nothing is shown on the screen.
- /* jump */
+ // jump
QString str = searchCombo->currentText();
if (str.isEmpty()) return ;
if (str.isEmpty()) return ;
if (datManager.checkWord(query, i, false)) {
- /* if this is parent, then show all responses, and search */
+ // if this is parent, then show all responses, and search
if (m_viewmode == VIEWMODE_MAINVIEW) m_threadPart->showAll();
insertSearchCombo();
// return ;
}
- /* view exists */
+ // view exists
WriteView* view = findWriteView(url);
if (view) {
if (view->body().length()) {
== KMessageBox::No) return;
}
- /* clear */
+ // clear
view->setMessage(resStr);
setCurrentWidget(view);
return ;
}
// TODO: refactoring.
- /* create new write view & add it to tab */
+ // create new write view & add it to tab
QString threadName;
- /* write res */
+ // write res
WriteView* new_dlg;
threadName = DatManager(url).threadName();
new_dlg = new WriteView(this, url);
int max = count();
if (max == 0) return ;
- /* disable all ok buttons. */
+ // disable all ok buttons.
for(int i=0; i < max ; i++) {
view = isWriteView(widget(i));
if (view) view->slotEnableWriting(false);
}
- /* show current url page. */
+ // show current url page.
view = findWriteView(url);
if (view) {
if (currentWidget() != view) setCurrentWidget(view);
void WriteView::initUI()
{
- /* connect signals */
+ // connect signals
connect(buttonOk, SIGNAL(clicked()),
SLOT(slotPostMessage()));
connect(bodyText, SIGNAL(textChanged()),
SLOT(slotBodyTextChanged()));
- /* setup preview view */
+ // setup preview view
qtw->setCurrentIndex(0);
- /* setup labels and edit lines */
+ // setup labels and edit lines
QFont font = GlobalConfig::threadFont();
bodyText->setFont(font);
bodyText->setTabChangesFocus(true);
beBox->setChecked(true);
}
- /* setup AA */
+ // setup AA
faceCombo->clear();
faceCombo->setFont(GlobalConfig::threadFont());
faceCombo->addItem("");
list.append(name);
GlobalConfig::setNameCompletionList(list);
- /* build post message */
+ // build post message
QString postStr = buildPostMessage();
- /* referrer */
+ // referrer
BoardDatabase db(m_datUrl);
QString refStr = db.boardUrl();
job->addMetaData("content-type", "Content-type: application/x-www-form-urlencoded");
job->addMetaData("referrer", refStr);
- /* 2ch.net cookie modify */
+ // 2ch.net cookie modify
if (m_bbstype == Board_2ch && beBox->isChecked()) {
QString cookie = "Cookie: ";
QString BeMailAddress = AccountConfig::beMailAddress();
connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
this, SLOT(slotRecieveData(KIO::Job*, const QByteArray&)));
- /* slotPostFinished() is called when done. */
+ // slotPostFinished() is called when done.
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotPostFinished(KJob*)));
case K2ch_True:
- /* save log */
+ // save log
logPostMessage();
- /* clear message */
+ // clear message
setMessage(QString());
- /* reload thread */
+ // reload thread
ViewMediator::getInstance()->openThread(m_datUrl);
m_parent->slotCloseCurrentTab();
break;
- /* eat cookie, then re-post message */
+ // eat cookie, then re-post message
case K2ch_Cookie:
if (KMessageBox::questionYesNo(0,
int length
= QTextCodec::codecForName("Shift_JIS")->fromUnicode(body()).length();
- /* replace '\n' -> " <br> ", '>' -> "<", and etc. */
+ // replace '\n' -> " <br> ", '>' -> "<", and etc.
length += ((body().count('\n')) * 5
+ (body().count('>')) * 3
+ (body().count('<')) * 3
/* get result code from 2ch tag or title. */ /* private */
int WriteView::resultCode(const QString& response) const
{
- /* see also libkita/kita-utf8.h */
+ // see also libkita/kita-utf8.h
QString errstr = QString::fromUtf8(KITAUTF8_WRITEERROR);
QString truestr = QString::fromUtf8(KITAUTF8_WRITETRUE);
QString ckstr = QString::fromUtf8(KITAUTF8_WRITECOOKIE);
int pos = regexp.indexIn(response);
if (pos != -1) {
- /* get code from 2ch tag */
+ // get code from 2ch tag
QString k2ch_X = regexp.cap(1);
if (k2ch_X == "true") return K2ch_True;
return K2ch_Unknown;
} else {
- /* get code from title */
+ // get code from title
QString title = resultTitle(response);
if (title.isEmpty()) return K2ch_Unknown;
if (title.contains(truestr)) return K2ch_True;
if (title.contains(ckstr)) return K2ch_Cookie;
- /* for Flash CGI */
+ // for Flash CGI
if (m_bbstype == Board_FlashCGI) {
if (title.contains("ERROR!!")) {
return K2ch_Error;
}
}
- /* for JBBS. adhoc... */
+ // for JBBS. adhoc...
if (m_bbstype == Board_JBBS) {
// x-euc-jp & euc-jp