[Kita-svn] [2433] enable the function of log deletion

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 7月 19日 (日) 06:54:08 JST


Revision: 2433
          http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2433
Author:   nogu
Date:     2009-07-19 06:54:08 +0900 (Sun, 19 Jul 2009)

Log Message:
-----------
enable the function of log deletion

Modified Paths:
--------------
    kita/branches/KITA-KDE4/kita/src/boardview.cpp
    kita/branches/KITA-KDE4/kita/src/threadlistview.cpp
    kita/branches/KITA-KDE4/kita/src/threadlistview.h

Modified: kita/branches/KITA-KDE4/kita/src/boardview.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/boardview.cpp	2009-07-18 21:07:43 UTC (rev 2432)
+++ kita/branches/KITA-KDE4/kita/src/boardview.cpp	2009-07-18 21:54:08 UTC (rev 2433)
@@ -15,6 +15,7 @@
 #include <QtGui/QApplication>
 #include <QtGui/QMouseEvent>
 
+#include <kaction.h>
 #include <kconfig.h>
 #include <kmessagebox.h>
 #include <kstandarddirs.h>
@@ -47,6 +48,8 @@
 
     loadLayout();
     loadHeaderOnOff();
+
+    m_deleteLogAct->setVisible(true);
 }
 
 /* public */

Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.cpp
===================================================================
--- kita/branches/KITA-KDE4/kita/src/threadlistview.cpp	2009-07-18 21:07:43 UTC (rev 2432)
+++ kita/branches/KITA-KDE4/kita/src/threadlistview.cpp	2009-07-18 21:54:08 UTC (rev 2433)
@@ -82,6 +82,15 @@
              SLOT(slotHideButton(bool)));
     connect(subjectList, SIGNAL(itemClicked(QTableWidgetItem*)),
              SLOT(slotItemClicked(QTableWidgetItem*)));
+
+    m_openWithBrowserAct
+        = new KAction(i18n("Open with Web Browser") , this);
+    m_copyURLAct = new KAction(i18n("Copy URL"), this);
+    m_copyTitleAndURLAct = new KAction(i18n("Copy title and URL"), this);
+    m_favoritesAct = new KAction(this);
+    m_deleteLogAct = new KAction(i18n("Delete Log"), this);
+    m_deleteLogAct->setVisible(false);
+    m_propertyAct = new KAction(i18n("Property"), this);
 }
 
 ThreadListView::~ThreadListView() {}
@@ -190,9 +199,8 @@
 
 void ThreadListView::contextMenuEvent(QContextMenuEvent *event)
 {
-    QTableWidgetItem* item
-        = subjectList->itemAt(subjectList->viewport()
-                ->mapFromGlobal(event->globalPos()));
+    QTableWidgetItem* item = subjectList->itemAt(
+            subjectList->viewport()->mapFromGlobal(event->globalPos()));
     if (item == 0) {
         return;
     }
@@ -203,56 +211,43 @@
     // create popup menu.
     KMenu popup(0);
 
-    KAction* openWithBrowserAct
-        = new KAction(i18n("Open with Web Browser") , this);
-    popup.addAction(openWithBrowserAct);
+    popup.addAction(m_openWithBrowserAct);
+    popup.addAction(m_copyURLAct);
+    popup.addAction(m_copyTitleAndURLAct);
 
-    KAction* copyURLAct = new KAction(i18n("Copy URL"), this);
-    popup.addAction(copyURLAct);
-
-    KAction* copyTitleAndURLAct = new KAction(i18n("Copy title and URL"), this);
-    popup.addAction(copyTitleAndURLAct);
-
     bool isFavorites = FavoriteThreads::getInstance()->contains(datURL);
-    KAction* favoritesAct = isFavorites
-        ? new KAction(i18n("Remove from Favorites"), this)
-        : new KAction(i18n("Add to Favorites"), this);
-    popup.addAction(favoritesAct);
+    m_favoritesAct->setText(isFavorites
+        ? i18n("Remove from Favorites") : i18n("Add to Favorites"));
+    popup.addAction(m_favoritesAct);
 
-    KAction* deleteLogAct = 0;
     if (DatManager::getReadNum(datURL)) {
         popup.addSeparator();
-
-        deleteLogAct = new KAction(i18n("Delete Log"), this);
-        popup.addAction(deleteLogAct);
+        popup.addAction(m_deleteLogAct);
     }
     popup.addSeparator();
+    popup.addAction(m_propertyAct);
 
-    KAction* propertyAct = new KAction(i18n("Property"), this);
-    popup.addAction(propertyAct);
-
     // exec popup menu.
     QClipboard* clipboard = QApplication::clipboard();
-    QString cliptxt;
 
     QAction* action = popup.exec(QCursor::pos());
     if (!action) {
         return;
     }
-    if (action == openWithBrowserAct) {
+    if (action == m_openWithBrowserAct) {
         KRun::runUrl(threadURL, "text/html", this);
-    } else if (action == copyURLAct) {
+    } else if (action == m_copyURLAct) {
         clipboard->setText(threadURL, QClipboard::Clipboard);
         clipboard->setText(threadURL, QClipboard::Selection);
-    } else if (action == copyTitleAndURLAct) {
-        cliptxt = DatManager::threadName(datURL) + '\n' + threadURL;
+    } else if (action == m_copyTitleAndURLAct) {
+        QString cliptxt = DatManager::threadName(datURL) + '\n' + threadURL;
         clipboard->setText(cliptxt , QClipboard::Clipboard);
         clipboard->setText(cliptxt , QClipboard::Selection);
-    } else if (action == favoritesAct) {
+    } else if (action == m_favoritesAct) {
         ViewMediator::getInstance()->bookmark(datURL, !isFavorites);
-    } else if (action == deleteLogAct) {
-        //deleteLog(threadURL); TODO
-    } else if (action == propertyAct) {
+    } else if (action == m_deleteLogAct) {
+        deleteLog(threadURL);
+    } else if (action == m_propertyAct) {
             QWidget* widget = new QWidget;
             Ui::ThreadProperty* propertyWidget
                 = new Ui::ThreadProperty;
@@ -288,4 +283,7 @@
     }
 }
 
+// dummy function. reimplemented in BoardView
+void ThreadListView::deleteLog(const KUrl&) {}
+
 #include "threadlistview.moc"

Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.h
===================================================================
--- kita/branches/KITA-KDE4/kita/src/threadlistview.h	2009-07-18 21:07:43 UTC (rev 2432)
+++ kita/branches/KITA-KDE4/kita/src/threadlistview.h	2009-07-18 21:54:08 UTC (rev 2433)
@@ -14,6 +14,8 @@
 
 #include "ui_threadlistviewbase.h"
 
+class KAction;
+
 struct ColumnAttribute
 {
     const char* labelName; /// for header's label
@@ -42,6 +44,7 @@
         QStringList m_prevquery;
         unsigned m_nextHitIndex;
         QList<QTableWidgetItem *> m_hitList;
+        KAction* m_deleteLogAct;
 
         void insertSearchCombo();
         void searchNext(const QStringList& input);
@@ -50,6 +53,7 @@
         void hideColumn(int col);
         void showColumn(int col);
         void contextMenuEvent(QContextMenuEvent* event);
+        virtual void deleteLog(const KUrl& url);
 
     protected slots:
         void slotHideButton(bool on);
@@ -58,6 +62,12 @@
     private slots:
         void slotSearchButton();
 
+    private:
+        KAction* m_openWithBrowserAct;
+        KAction* m_copyURLAct;
+        KAction* m_copyTitleAndURLAct;
+        KAction* m_favoritesAct;
+        KAction* m_propertyAct;
     };
 }
 




Kita-svn メーリングリストの案内
Back to archive index