Changeset 196
- Timestamp:
- 03/29/09 06:24:36 (3 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
forum_tree.cpp (modified) (22 diffs)
-
forum_tree.h (modified) (2 diffs)
-
iforum_tree.h (modified) (1 diff)
-
message_tree.cpp (modified) (16 diffs)
-
message_tree.h (modified) (1 diff)
-
model/forum.h (modified) (1 diff)
-
storage/istorage.h (modified) (1 diff)
-
storage/mysql_storage.cpp (modified) (6 diffs)
-
storage/mysql_storage.h (modified) (1 diff)
-
version.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum_tree.cpp
r192 r196 9 9 #include "model/all.h" 10 10 #include "form_date.h" 11 #include "icon_effect.h" 11 12 #include "form_message.h" 12 13 #include "tree_widget_item.h" … … 23 24 typedef struct AForumInfoGUI 24 25 { 25 AForumInfo Info; 26 int UnreadCount; 26 AForumInfo Info; /*!< \brief Описатель форума */ 27 int UnreadCount; /*!< \brief Количество непрочитанных сообщений */ 28 int UnreadCountMy; /*!< \brief Количество непрочитанных сообщений мне */ 27 29 } AForumInfoGUI; 28 30 //---------------------------------------------------------------------------------------------- … … 35 37 AForumTree::AForumTree (QWidget* parent, QWidget* form) : QTreeWidget (parent), IForumTree () 36 38 { 39 // 40 // инициализация полей 41 // 42 37 43 m_parent = form; 38 44 m_message_tree = 0; … … 44 50 m_specail_group_count = 0; 45 51 52 // 53 // инициализация GUI виджета 54 // 55 46 56 setFrameShadow(QFrame::Plain); 47 57 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); … … 57 67 headerItem()->setTextAlignment(1, Qt::AlignCenter); 58 68 69 // 70 // контекстное меню 71 // 72 59 73 m_menu = new QMenu(this); 60 74 … … 78 92 m_menu_unsubscribe->setIcon(QIcon(":/icons/unsubscribe16.png")); 79 93 94 // 95 // иконки статусов форумов 96 // 97 98 m_forum_read = QIcon(":/icons/messageread.png"); 99 m_forum_unread = QIcon(":/icons/messageunread.png"); 100 m_forum_unread_my = AIconEffect::unionIcons(":/icons/messageunread.png", ":/icons/myunread.png"); 101 102 // 103 // события виджета 104 // 105 80 106 connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(current_item_changed(QTreeWidgetItem*, QTreeWidgetItem*))); 81 107 connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(context_menu_request(const QPoint&))); 108 109 // 110 // события меню 111 // 82 112 83 113 connect(m_menu_mark_all_as_read, SIGNAL(triggered()), this, SLOT(menu_mark_all_as_read_triggered())); … … 144 174 } 145 175 176 // получение информации о себе 177 // TODO: вынести в AGlobal 178 QSettings settings; 179 AUserInfo me; 180 181 me.Name = settings.value("rsdn/login", "").toString(); 182 183 if (storage->whoAmI(me, NULL) == false) 184 me.Name = ""; 185 146 186 // получение списка форумов 147 187 AForumGroupInfoList list; … … 156 196 AUnreadForumCountInfoList unread; 157 197 158 if (storage->getUnreadCount(unread, NULL) == false)198 if (storage->getUnreadCount(unread, me.ID, NULL) == false) 159 199 { 160 200 storage->showError(m_parent); … … 232 272 AForumInfoGUI info; 233 273 234 info.Info = list[group_index].Forums[forum_index]; 235 info.UnreadCount = 0; 274 info.Info = list[group_index].Forums[forum_index]; 275 info.UnreadCount = 0; 276 info.UnreadCountMy = 0; 236 277 237 278 forum_item->setTag(info); … … 240 281 241 282 forum_item->setTextAlignment(1, Qt::AlignCenter); 283 284 /* 285 // установка иконок форумов для спец группы 286 // (внешний вид мне не нравится, по этому убрано) 287 if (info.Info.IDGroup == SPECIAL_ID_GROUP) 288 { 289 if (info.Info.ID == SPECIAL_ID_FORUM_MESSAGE2SEND) 290 forum_item->setIcon(0, QIcon(":/icons/new16.png")); 291 else if (info.Info.ID == SPECIAL_ID_FORUM_RATING2SEND) 292 forum_item->setIcon(0, QIcon(":/icons/rate_plus.png")); 293 else if (info.Info.ID == SPECIAL_ID_FORUM_MODERATE2SEND) 294 forum_item->setIcon(0, QIcon(":/icons/moderate.png")); 295 } 296 */ 242 297 243 298 // поиск количества непрочитаных сообщений … … 255 310 m_total_unread_count += unread_count; 256 311 257 forum_item->pag()->UnreadCount = unread_count; 312 forum_item->pag()->UnreadCount = unread_count; 313 forum_item->pag()->UnreadCountMy = unread[i].CountMy; 258 314 259 315 forum_item->setText(1, QString::number(unread_count)); … … 263 319 forum_item->setFont(1, font); 264 320 321 if (list[group_index].Forums[forum_index].IDGroup != SPECIAL_ID_GROUP) 322 { 323 if (unread[i].CountMy > 0) 324 forum_item->setIcon(0, m_forum_unread_my); 325 else 326 forum_item->setIcon(0, m_forum_unread); 327 } 328 265 329 found = true; 266 330 … … 275 339 font.setBold(false); 276 340 forum_item->setFont(1, font); 341 342 if (list[group_index].Forums[forum_index].IDGroup != SPECIAL_ID_GROUP) 343 forum_item->setIcon(0, m_forum_read); 277 344 } 278 345 } … … 308 375 } 309 376 377 // получение информации о себе 378 // TODO: вынести в AGlobal 379 QSettings settings; 380 AUserInfo me; 381 382 me.Name = settings.value("rsdn/login", "").toString(); 383 384 if (storage->whoAmI(me, NULL) == false) 385 me.Name = ""; 386 310 387 // получение количества непрочитаных сообщений 311 388 AUnreadForumCountInfoList unread; 312 389 313 if (storage->getUnreadCount(unread, NULL) == false)390 if (storage->getUnreadCount(unread, me.ID, NULL) == false) 314 391 { 315 392 storage->showError(m_parent); … … 344 421 m_total_unread_count += unread_count; 345 422 346 pitem->UnreadCount = unread_count; 423 pitem->UnreadCount = unread_count; 424 pitem->UnreadCountMy = unread[i].CountMy; 347 425 348 426 forum_item->setText(1, QString::number(unread_count)); … … 352 430 forum_item->setFont(1, font); 353 431 432 if (pitem->Info.IDGroup != SPECIAL_ID_GROUP) 433 { 434 if (unread[i].CountMy > 0) 435 forum_item->setIcon(0, m_forum_unread_my); 436 else 437 forum_item->setIcon(0, m_forum_unread); 438 } 439 354 440 found = true; 355 441 … … 359 445 if (found == false) 360 446 { 361 pitem->UnreadCount = 0; 447 pitem->UnreadCount = 0; 448 pitem->UnreadCountMy = 0; 362 449 363 450 forum_item->setText(1, "-"); … … 366 453 font.setBold(false); 367 454 forum_item->setFont(1, font); 455 456 if (pitem->Info.IDGroup != SPECIAL_ID_GROUP) 457 forum_item->setIcon(0, m_forum_read); 368 458 } 369 459 } … … 457 547 //---------------------------------------------------------------------------------------------- 458 548 459 void AForumTree::changeUnreadCount (int count )549 void AForumTree::changeUnreadCount (int count, int count_my) 460 550 { 461 551 ForumTreeWidgetItem* forum_item = static_cast<ForumTreeWidgetItem*>(getSelectedForumItem()); … … 464 554 return; 465 555 466 forum_item->pag()->UnreadCount += count; 556 forum_item->pag()->UnreadCount += count; 557 forum_item->pag()->UnreadCountMy += count_my; 467 558 468 559 if (forum_item->pag()->UnreadCount != 0) … … 474 565 forum_item->setFont(1, font); 475 566 567 if (forum_item->pag()->Info.IDGroup != SPECIAL_ID_GROUP) 568 { 569 if (forum_item->pag()->UnreadCountMy > 0) 570 forum_item->setIcon(0, m_forum_unread_my); 571 else 572 forum_item->setIcon(0, m_forum_unread); 573 } 574 476 575 // установка возможных действий 477 576 m_main_form->setEnabledAction(aaPrevNextUnreadArticle, true); … … 485 584 font.setBold(false); 486 585 forum_item->setFont(1, font); 586 587 if (forum_item->pag()->Info.IDGroup != SPECIAL_ID_GROUP) 588 forum_item->setIcon(0, m_forum_read); 487 589 488 590 // установка возможных действий -
trunk/forum_tree.h
r131 r196 72 72 int m_specail_group_count; /*!< \brief Общее количество спец-групп форумов */ 73 73 74 // 75 // иконки для отображения статусов сообщений 76 // 77 78 QIcon m_forum_read; /*!< \brief Все сообщения прочитанны */ 79 QIcon m_forum_unread; /*!< \brief Есть непрочитанные сообщения */ 80 QIcon m_forum_unread_my; /*!< \brief Есть непрочитанные сообщения для меня */ 81 74 82 /*! 75 83 * \brief Функция проверки установки выделения, в случае отсутствия выделения, выделяет самый верхний элемент … … 115 123 void reloadUnread (bool reload_message_tree); 116 124 117 void changeUnreadCount (int count );125 void changeUnreadCount (int count, int count_my); 118 126 119 127 void newMessage (); -
trunk/iforum_tree.h
r131 r196 38 38 * отрицательное значение уменьшает число на count, 39 39 * проверка соответствия итогового значения с реальным числом непрочитанных сообщений в дереве сообщений не производится. 40 * \param count_my дельта числа непрочитанных сообщений мне (по аналогии с параметром count) 40 41 */ 41 virtual void changeUnreadCount (int count ) = 0;42 virtual void changeUnreadCount (int count, int count_my) = 0; 42 43 43 44 /*! -
trunk/message_tree.cpp
r191 r196 895 895 // и должна произойти смена иконки 896 896 if (old_unread_count_my != 0 && info_parent->UnreadChildCountMy == 0) 897 item_parent->setIcon(0, m_message_unread); 897 { 898 // исключение составляет момент, когда элемент, у которого должна поменяться иконка 899 // сам по себе является ответом мне. В этом случае, у него свойства 900 // HasUnreadChildMy = false и UnreadChildCountMy = 0, однако, поскольку он является ответом мне 901 // то пометка с него сниматься не должна 902 903 MessageTreeWidgetItem* item_parent_parent = static_cast<MessageTreeWidgetItem*>(item_parent->parent()); 904 905 if (item_parent_parent == NULL || item_parent_parent->pag()->IDUser != m_me.ID) 906 item_parent->setIcon(0, m_message_unread); 907 } 898 908 } 899 909 else 900 910 { 911 // TODO: уменьшить возможное количество смен иконок на точно такие же 912 901 913 // родитель прочитан 902 914 … … 909 921 // и должна произойти смена иконки 910 922 else if (old_unread_count != info_parent->UnreadChildCount && info_parent->UnreadChildCount > 0) 911 item_parent->setIcon(0, m_child_unread); 923 { 924 // если, конечно, нет непрочитанных мне 925 if (info_parent->UnreadChildCountMy == 0) 926 item_parent->setIcon(0, m_child_unread); 927 } 912 928 913 929 // нет дочерних непрочитанных … … 920 936 921 937 // уменьшение количества непрочитанных в дереве форума 922 m_forum_tree->changeUnreadCount(-1); 938 if (message_to_me == true) 939 m_forum_tree->changeUnreadCount(-1, -1); 940 else 941 m_forum_tree->changeUnreadCount(-1, 0); 923 942 } 924 943 else // if (is_read == true) 925 944 { 926 // TODO: Доделать пометку родителей, если отметилось сообщение, которое является ответом мне 927 928 // установка иконки помечаемому сообщению 929 item->setIcon(0, m_message_unread); 945 // флаг того, что это было сообщение для меня 946 bool message_to_me = false; 930 947 931 948 // установка флагов и иконок у родительских сообщений 932 949 MessageTreeWidgetItem* parent_item = static_cast<MessageTreeWidgetItem*>(item->parent()); 933 950 951 // для текущего сообщения 952 if (parent_item != NULL && parent_item->pag()->IDUser == m_me.ID) 953 message_to_me = true; 954 955 if (message_to_me == true || info->HasUnreadChildMy == true) 956 item->setIcon(0, m_message_unread_my); 957 else 958 item->setIcon(0, m_message_unread); 959 960 // для родительских сообщений 934 961 while (parent_item != NULL) 935 962 { … … 938 965 // смена иконки при необходимости 939 966 if (parent_info->IsRead == true && parent_info->HasUnreadChild == false) 940 parent_item->setIcon(0, m_child_unread); 967 { 968 if (message_to_me == true) 969 parent_item->setIcon(0, m_child_unread_my); 970 else 971 parent_item->setIcon(0, m_child_unread); 972 } 941 973 942 974 parent_info->UnreadChildCount++; 943 975 parent_info->HasUnreadChild = true; 944 976 977 if (message_to_me == true) 978 { 979 parent_info->UnreadChildCountMy++; 980 parent_info->HasUnreadChildMy = true; 981 } 982 945 983 parent_item = static_cast<MessageTreeWidgetItem*>(parent_item->parent()); 946 984 } 947 985 948 986 // увеличение количества непрочитанных в дереве форума 949 m_forum_tree->changeUnreadCount(1); 987 if (message_to_me == true) 988 m_forum_tree->changeUnreadCount(1, 1); 989 else 990 m_forum_tree->changeUnreadCount(1, 0); 950 991 951 992 } // if (is_read == true) ... else … … 955 996 void AMessageTree::menu_mark_message_as_read_triggered () 956 997 { 998 // остановка таймера пометки как прочитанного, т.к. его операция должна быть в любом случае прервана 999 m_timer.stop(); 1000 957 1001 QTreeWidgetItem* item = currentItem(); 958 1002 … … 966 1010 void AMessageTree::menu_mark_message_as_unread_triggered () 967 1011 { 1012 // остановка таймера пометки как прочитанного, т.к. его операция должна быть в любом случае прервана 1013 m_timer.stop(); 1014 968 1015 QTreeWidgetItem* item = currentItem(); 969 1016 … … 997 1044 void AMessageTree::menu_mark_thread_as_read_triggered () 998 1045 { 1046 // остановка таймера пометки как прочитанного, т.к. его операция должна быть в любом случае прервана 1047 m_timer.stop(); 1048 999 1049 QTreeWidgetItem* item = currentItem(); 1000 1050 … … 1014 1064 if (info->IsChildLoaded == true) 1015 1065 { 1016 int count = 0; 1017 1018 markThreadAsRead(parent, true, count); 1019 1020 m_forum_tree->changeUnreadCount(-count); 1066 int count = 0; 1067 int count_my = 0; 1068 1069 markThreadAsRead(parent, true, count, count_my); 1070 1071 m_forum_tree->changeUnreadCount(-count, -count_my); 1021 1072 } 1022 1073 else … … 1040 1091 void AMessageTree::menu_mark_thread_as_unread_triggered () 1041 1092 { 1093 // остановка таймера пометки как прочитанного, т.к. его операция должна быть в любом случае прервана 1094 m_timer.stop(); 1095 1042 1096 QTreeWidgetItem* item = currentItem(); 1043 1097 … … 1057 1111 if (info->IsChildLoaded == true) 1058 1112 { 1059 int count = 0; 1060 1061 markThreadAsRead(parent, false, count); 1062 1063 m_forum_tree->changeUnreadCount(count); 1113 int count = 0; 1114 int count_my = 0; 1115 1116 markThreadAsRead(parent, false, count, count_my); 1117 1118 m_forum_tree->changeUnreadCount(count, count_my); 1064 1119 } 1065 1120 else … … 1079 1134 // обновление количества непрочитаных в дереве форума 1080 1135 m_forum_tree->reloadUnread(false); 1136 1137 // перегружаем информацию о топике (возможно, что есть непрочитанные сообщения для меня) 1138 info->IsInfoLoaded = false; 1139 1140 scrollTopics(); 1081 1141 } 1082 1142 } … … 1895 1955 //---------------------------------------------------------------------------------------------- 1896 1956 1897 void AMessageTree::markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count )1957 void AMessageTree::markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count, int& count_my) 1898 1958 { 1899 1959 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(parent); … … 1909 1969 { 1910 1970 item->setIcon(0, m_message_read); 1971 1972 if (info->UnreadChildCountMy > count_my) 1973 count_my = info->UnreadChildCountMy; 1911 1974 1912 1975 info->HasUnreadChild = false; … … 1916 1979 1917 1980 for (int i = 0; i < item->childCount(); i++) 1918 markThreadAsRead(item->child(i), is_read, count );1981 markThreadAsRead(item->child(i), is_read, count, count_my); 1919 1982 } 1920 1983 else // if (is_read == true) 1921 1984 { 1922 item->setIcon(0, m_message_unread);1923 1924 1985 info->HasUnreadChild = false; 1925 1986 info->HasUnreadChildMy = false; … … 1927 1988 info->UnreadChildCountMy = 0; 1928 1989 1990 // флаг того, что есть дочерние сообщения для меня 1991 bool inc_unread_my = false; 1992 1929 1993 MessageTreeWidgetItem* parent = static_cast<MessageTreeWidgetItem*>(item->parent()); 1930 1994 1995 // установка иконки на текущее сообщение, если это ответ мне 1996 if (parent != NULL && parent->pag()->IDUser == m_me.ID) 1997 { 1998 count_my++; 1999 inc_unread_my = true; 2000 item->setIcon(0, m_message_unread_my); 2001 } 2002 else 2003 item->setIcon(0, m_message_unread); 2004 1931 2005 while (parent != NULL) 1932 2006 { 1933 2007 info = parent->pag(); 2008 2009 if (inc_unread_my == true) 2010 { 2011 if (info->HasUnreadChildMy == false) 2012 parent->setIcon(0, m_message_unread_my); 2013 2014 info->HasUnreadChildMy = true; 2015 info->UnreadChildCountMy++; 2016 } 1934 2017 1935 2018 info->HasUnreadChild = true; … … 1940 2023 1941 2024 for (int i = 0; i < item->childCount(); i++) 1942 markThreadAsRead(item->child(i), is_read, count );2025 markThreadAsRead(item->child(i), is_read, count, count_my); 1943 2026 1944 2027 } // if (is_read == true) ... else -
trunk/message_tree.h
r191 r196 189 189 * \param is_read Флаг прочитанного 190 190 * \param count Количество элементов, которые были помечены 191 */ 192 void markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count); 191 * \param count Количество элементов, которые были помечены и являлись ответами мне 192 */ 193 void markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count, int& count_my); 193 194 194 195 /* -
trunk/model/forum.h
r118 r196 52 52 typedef struct AUnreadForumCountInfo 53 53 { 54 int IDForum; /*!< \brief ID форума */ 55 int Count; /*!< \brief Количество непрочитанных сообщений */ 54 int IDForum; /*!< \brief ID форума */ 55 int Count; /*!< \brief Количество непрочитанных сообщений */ 56 int CountMy; /*!< \brief Количество непрочитанных сообщений мне */ 56 57 } AUnreadForumCountInfo; 57 58 -
trunk/storage/istorage.h
r191 r196 122 122 * в т.ч. и для спец-группы "Локальные" (см. константы SPECIAL_ID_FORUM_xxx в model/forum.h). 123 123 * \param list Список с количеством непрочитанных сообщений для id форумов. 124 * \param progress Прогресс выполнения операции. 125 */ 126 virtual bool getUnreadCount (AUnreadForumCountInfoList& list, IProgress* progress = NULL) = 0; 124 * \param id_me ID текущего пользователя avalon. 125 * \param progress Прогресс выполнения операции. 126 */ 127 virtual bool getUnreadCount (AUnreadForumCountInfoList& list, int id_me, IProgress* progress = NULL) = 0; 127 128 128 129 /*! -
trunk/storage/mysql_storage.cpp
r191 r196 1702 1702 //---------------------------------------------------------------------------------------------- 1703 1703 1704 bool AMySQLStorage::getUnreadCount (AUnreadForumCountInfoList& list, IProgress* progress)1704 bool AMySQLStorage::getUnreadCount (AUnreadForumCountInfoList& list, int id_me, IProgress* progress) 1705 1705 { 1706 1706 if (progress != NULL) … … 1711 1711 sql += "SELECT\n"; 1712 1712 sql += " `id_forum`,\n"; 1713 sql += " COUNT(*)\n"; 1713 sql += " COUNT(*),\n"; 1714 sql += " SUM(IF(`id_parent_user` = " + QString::number(id_me) + ", 1, 0))\n"; 1714 1715 sql += "FROM\n"; 1715 1716 sql += " `unread`\n"; … … 1731 1732 info.IDForum = query_select->value(0).toInt(); 1732 1733 info.Count = query_select->value(1).toInt(); 1734 info.CountMy = query_select->value(2).toInt(); 1733 1735 1734 1736 list.append(info); … … 1760 1762 info_message.IDForum = SPECIAL_ID_FORUM_MESSAGE2SEND; 1761 1763 info_message.Count = query_message->value(0).toInt(); 1764 info_message.CountMy = 0; 1762 1765 1763 1766 if (info_message.Count > 0) … … 1785 1788 info_rating.IDForum = SPECIAL_ID_FORUM_RATING2SEND; 1786 1789 info_rating.Count = query_rating->value(0).toInt(); 1790 info_rating.CountMy = 0; 1787 1791 1788 1792 if (info_rating.Count > 0) … … 1810 1814 info_moderate.IDForum = SPECIAL_ID_FORUM_MODERATE2SEND; 1811 1815 info_moderate.Count = query_moderate->value(0).toInt(); 1816 info_moderate.CountMy = 0; 1812 1817 1813 1818 if (info_moderate.Count > 0) -
trunk/storage/mysql_storage.h
r191 r196 55 55 bool getMessageQuery (ADataQuery& query, IProgress* progress = NULL); 56 56 bool setMessageList (const ADataList& list, const ARowVersion& row_version, bool save_row_version, IProgress* progress = NULL); 57 bool getUnreadCount (AUnreadForumCountInfoList& list, IProgress* progress = NULL);57 bool getUnreadCount (AUnreadForumCountInfoList& list, int id_me, IProgress* progress = NULL); 58 58 bool getForumTopicList (int id_forum, int count, QList<int>& list, IProgress* progress = NULL); 59 59 bool getTopicInfoList (int id_forum, AMessageInfoGUIPtrList& list, int id_me, IProgress* progress = NULL); -
trunk/version.h
r195 r196 20 20 * \brief Дата билда (заменяется автоматически при каждом билде в version.h, что и приводит к смене номера ревизии) 21 21 */ 22 #define AVALON_DATE " Сбт Мар 28 10:17:52 MSK2009"22 #define AVALON_DATE "Вск Мар 29 06:22:19 MSD 2009" 23 23 24 24 #endif
Note: See TracChangeset
for help on using the changeset viewer.
