// and a status bar
statusBar()->show();
- // setup cache
- setupCache();
-
// apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar
// position, icon size, etc.
setAutoSaveSettings();
// allow the view to change the statusbar and caption
- connect(m_threadview, SIGNAL(signalChangeStatusbar(const QString&)),
+ connect(m_threadView, SIGNAL(signalChangeStatusbar(const QString&)),
this, SLOT(changeStatusbar(const QString&)));
connect(m_boardView, SIGNAL(signalLoadBoard(const KURL&, const QString&)),
m_subjectView, SLOT(slotLoadBoard(const KURL&, const QString&)));
connect(m_subjectView, SIGNAL(signalShowThread(const KURL&, const KURL&, const QString&)),
- m_threadview, SLOT(slotShowThread(const KURL&, const KURL&, const QString&)));
+ m_threadView, SLOT(slotShowThread(const KURL&, const KURL&, const QString&)));
// connect(m_view, SIGNAL(signalChangeCaption(const QString&)),
// this, SLOT(changeCaption(const QString&)));
- connect(m_threadview, SIGNAL(setVestedNum(const KURL&, int)), SLOT(slotSetVestedNum(const KURL&, int)));
+ connect(m_threadView, SIGNAL(setVestedNum(const KURL&, int)), SLOT(slotSetVestedNum(const KURL&, int)));
m_boardView->loadBoardList();
}
{
KDockWidget* mainDock;
mainDock = createDockWidget("main", 0L, 0L, i18n("main"));
- m_threadview = new KitaThreadView(mainDock);
- mainDock->setWidget(m_threadview);
+ m_threadView = new KitaThreadView(mainDock);
+ mainDock->setWidget(m_threadView);
mainDock->setDockSite(KDockWidget::DockFullSite);
mainDock->setEnableDocking(KDockWidget::DockNone);
- connect( m_threadview, SIGNAL( openURLRequest(const KURL&, const KParts::URLArgs&) ),
+ connect( m_threadView, SIGNAL( openURLRequest(const KURL&, const KParts::URLArgs&) ),
SLOT( slotOpenURLRequest(const KURL&, const KParts::URLArgs&) ) );
KDockWidget* subjectDock;
subjectDock = createDockWidget("subject", 0L, 0L, i18n("subject"));
m_subjectView = new KitaSubjectView(subjectDock);
+ m_subjectView->setKita(this);
subjectDock->setWidget(m_subjectView);
subjectDock->setDockSite(KDockWidget::DockFullSite);
{
new KRun(url);
}
-#include "kita.moc"
-
-void Kita::setupCache()
-{
- m_cache = new KitaCacheInfo();
-}
-void Kita::slotSetVestedNum(const KURL& threadURL, int resNum)
+void Kita::slotSetVestedNum(const KURL& threadURL, int resCount)
{
- m_cache->setVestedNum(threadURL, resNum);
-}
-
-KitaCacheInfo* Kita::getCache()
-{
- return m_cache;
+ KitaCacheInfo::getInstance()->setVestedNum(threadURL, resCount);
}
+#include "kita.moc"
class KitaThreadView;
class KitaBoardView;
class KitaSubjectView;
-class KitaCacheInfo;
namespace KParts{
class URLArgs;
* Use this method to load whatever file/URL you have
*/
void load(const KURL& url);
- KitaCacheInfo* getCache();
protected:
/**
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
-protected:
/**
* This function is called when it is time for the app to save its
* properties for session management purposes.
*/
void readProperties(KConfig *);
-
private slots:
void fileNew();
void fileOpen();
void changeStatusbar(const QString& text);
void changeCaption(const QString& text);
void slotOpenURLRequest(const KURL& url, const KParts::URLArgs&);
+ void slotSetVestedNum(const KURL& threadURL, int resCount);
private:
- void setupAccel();
- void setupActions();
- void setupView();
- void setupCache();
-
-private:
- KitaThreadView *m_threadview;
+ KitaThreadView *m_threadView;
KitaBoardView* m_boardView;
KitaSubjectView* m_subjectView;
KPrinter *m_printer;
KToggleAction *m_toolbarAction;
KToggleAction *m_statusbarAction;
- KitaCacheInfo* m_cache;
-public slots:
- void slotSetVestedNum(const KURL& threadURL, int resNum);
+
+ void setupAccel();
+ void setupActions();
+ void setupView();
};
#endif // _KITA_H_
#include <qmap.h>
-KitaCacheInfo::KitaCacheInfo()
+KitaCacheInfo* KitaCacheInfo::instance = 0;
+
+KitaCacheInfo::KitaCacheInfo() : m_vestedDict()
{
- m_vestedDict = new QMap<QString, int>();
}
KitaCacheInfo::~KitaCacheInfo()
{
- delete m_vestedDict;
+}
+
+KitaCacheInfo* KitaCacheInfo::getInstance()
+{
+ if( instance == 0 ) {
+ instance = new KitaCacheInfo();
+ }
+ return instance;
}
int KitaCacheInfo::getVestedNum(const KURL& url)
{
- return 0;
+ QString key = url.prettyURL();
+ if(m_vestedDict.contains(key)) {
+ return m_vestedDict[key];
+ } else {
+ return 0;
+ }
}
void KitaCacheInfo::setVestedNum(const KURL& url, int num)
{
- m_vestedDict->insert(url.prettyURL(), num);
+ m_vestedDict.insert(url.prettyURL(), num);
}
class KitaCacheInfo
{
public:
- KitaCacheInfo();
- ~KitaCacheInfo();
+ static KitaCacheInfo* getInstance();
void setVestedNum(const KURL& url, int num);
int getVestedNum(const KURL& url);
private:
- QMap<QString, int>* m_vestedDict;
+ KitaCacheInfo();
+ ~KitaCacheInfo();
+ QMap<QString, int> m_vestedDict;
+ static KitaCacheInfo* instance;
};
#endif
KitaSubjectView::KitaSubjectView(QWidget *parent, const char *name)
: KitaSubjectViewBase(parent, name)
{
- m_parent = static_cast<Kita*>(parent);
{
SearchButton->setPixmap( SmallIcon("find") );
HideButton->setPixmap( SmallIcon("filter") );
{
}
+void KitaSubjectView::setKita(Kita* kita)
+{
+ m_kita = kita;
+}
+
void KitaSubjectView::reloadSubject()
{
}
QString line;
int row=1;
- KitaCacheInfo* cache = m_parent->getCache();
+ KitaCacheInfo* cache = KitaCacheInfo::getInstance();
while((line = stream.readLine()) != QString::null) {
int pos = regexp.search(line);
QString subject = regexp.cap(2);
QString num = regexp.cap(3);
- new KListViewItem(subjectList, QString("%1").arg(row, 4), "", subject, QString("%1").arg(num, 4), "", fname);
+ KURL datURL = m_boardURL;
+ datURL.addPath("/dat/" + fname);
+ int vested = cache->getVestedNum(datURL);
+ new KListViewItem(subjectList,
+ QString("%1").arg(row, 4),
+ "",
+ subject,
+ QString("%1").arg(num, 4),
+ vested > 0 ? QString::number(vested) : "",
+ fname);
row++;
}
}
public:
KitaSubjectView(QWidget *parent, const char *name=0);
~KitaSubjectView();
+ void setKita(Kita* kita);
public slots:
void reloadSubject();
void loadThread(QListViewItem* item);
void slotLoadBoard(const KURL& url, const QString& boardName);
void slotHideButton(bool on);
private: // Private attributes
- Kita* m_parent;
+ Kita* m_kita;
KURL m_boardURL;
QString m_boardName;
void insertSearchCombo();
#include "kitathreadview.h"
#include "kitawritedialog.h"
+#include "../kitacacheinfo.h"
#include <qmessagebox.h>
}
delete progress;
m_rescount = num - 1;
- emit setVestedNum(m_threadURL, m_rescount);
+ emit setVestedNum(m_datURL, m_rescount);
{
int target;