Changeset 188
- Timestamp:
- 03/27/09 14:56:44 (3 years ago)
- Location:
- branches/message_tree
- Files:
-
- 5 edited
-
message_tree.cpp (modified) (11 diffs)
-
message_tree.h (modified) (2 diffs)
-
model/message.h (modified) (1 diff)
-
storage/mysql_storage.cpp (modified) (1 diff)
-
version.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/message_tree/message_tree.cpp
r187 r188 453 453 } 454 454 455 // обновление в дереве форумов количества непрочитан ых сообщений455 // обновление в дереве форумов количества непрочитанных сообщений 456 456 if (m_forum_tree != NULL) 457 457 m_forum_tree->reloadUnread(false); … … 554 554 } 555 555 556 // обновление в дереве форумов количества непрочитан ых сообщений556 // обновление в дереве форумов количества непрочитанных сообщений 557 557 if (m_forum_tree != NULL) 558 558 m_forum_tree->reloadUnread(true); … … 773 773 //---------------------------------------------------------------------------------------------- 774 774 775 void AMessageTree::gotoNextUnreadArticle ( )775 void AMessageTree::gotoNextUnreadArticle (QTreeWidgetItem* current_item) 776 776 { 777 777 AMessageInfoGUI* info = NULL; 778 778 779 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(current Item());779 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(current_item); 780 780 781 781 // если не было выделения, то ищем первый непрочитанный топик или топик с непрочитанными сообщениями … … 886 886 //---------------------------------------------------------------------------------------------- 887 887 888 void AMessageTree::gotoNextUnreadArticle () 889 { 890 gotoNextUnreadArticle(currentItem()); 891 } 892 //---------------------------------------------------------------------------------------------- 893 888 894 void AMessageTree::gotoNextUnreadThread () 889 895 { … … 895 901 if (item == NULL) 896 902 { 897 gotoNextUnreadArticle( );903 gotoNextUnreadArticle(NULL); 898 904 return; 899 905 } 900 906 901 907 // item установлен на топик 902 item = ATreeWidgetItem::rootItem(item);908 item = static_cast<MessageTreeWidgetItem*>(ATreeWidgetItem::rootItem(item)); 903 909 info = item->pag(); 904 910 … … 906 912 bool loopback = false; 907 913 908 // поиск следующего топика с непрочитанными 914 // поиск следующего топика с непрочитанными сообщениями 909 915 while (true) 910 916 { 911 917 // следующий топик за текущим 912 MessageTreeWidgetItem* item = ATreeWidgetItem::nextSibling(item);918 item = static_cast<MessageTreeWidgetItem*>(ATreeWidgetItem::nextSibling(item)); 913 919 914 920 // если достигнут конец дерева, то переходим в корень … … 929 935 loopback = true; 930 936 } 931 else if (info->IsRead == false) 937 938 if (info->IsRead == false) 932 939 break; 933 else if (info->HasUnreadChild == true) 934 { 935 DONT COMPILE THIS!!! 940 941 if (info->HasUnreadChild == true) 942 { 943 gotoNextUnreadArticle(item); 944 return; 936 945 } 937 946 } … … 945 954 void AMessageTree::menu_mark_message_as_read_triggered () 946 955 { 956 QTreeWidgetItem* item = currentItem(); 957 958 if (item == NULL) 959 return; 960 961 markItemAsRead(item, true); 947 962 } 948 963 //---------------------------------------------------------------------------------------------- … … 950 965 void AMessageTree::menu_mark_message_as_unread_triggered () 951 966 { 952 } 953 //---------------------------------------------------------------------------------------------- 954 955 void AMessageTree::menu_mark_thread_as_read_triggered () 956 { 957 } 958 //---------------------------------------------------------------------------------------------- 959 960 void AMessageTree::menu_mark_thread_as_unread_triggered () 961 { 967 QTreeWidgetItem* item = currentItem(); 968 969 if (item == NULL) 970 return; 971 972 markItemAsRead(item, false); 962 973 } 963 974 //---------------------------------------------------------------------------------------------- … … 965 976 void AMessageTree::timer_on_timer () 966 977 { 978 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(currentItem()); 979 980 if (item != NULL) 981 markItemAsRead(item, true); 982 } 983 //---------------------------------------------------------------------------------------------- 984 985 void AMessageTree::markItemAsRead (QTreeWidgetItem* widget_item, bool is_read) 986 { 987 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(widget_item); 988 989 AMessageInfoGUI* info = item->pag(); 990 991 // если уже прочитан 992 if (info->IsRead == is_read) 993 return; 994 995 // пометить как прочитанное в хранилище 996 std::auto_ptr<IAStorage> storage(AStorageFactory::getStorage()); 997 998 if (storage.get() == NULL) 999 { 1000 QMessageBox::critical(m_parent, QString::fromUtf8("Ошибка!"), QString::fromUtf8("Не выбрано хранилище данных")); 1001 return; 1002 } 1003 1004 if (storage->setIDsAsRead(QList<int>() << info->ID, idsMessage, is_read, QDateTime(), NULL) == false) 1005 { 1006 storage->showError(m_parent); 1007 return; 1008 } 1009 1010 // установка флага как прочитанного и пометка в дереве 1011 info->IsRead = is_read; 1012 1013 if (is_read == true) 1014 { 1015 // установка иконки помечаемому сообщению 1016 if (info->HasUnreadChildMy) 1017 item->setIcon(0, m_child_unread_my); 1018 else if (info->HasUnreadChild) 1019 item->setIcon(0, m_child_unread); 1020 else 1021 item->setIcon(0, m_message_read); 1022 1023 // флаг того, что это было сообщение для меня 1024 bool message_to_me = false; 1025 1026 // установка флагов и иконок у родительских сообщений 1027 MessageTreeWidgetItem* item_parent = static_cast<MessageTreeWidgetItem*>(item->parent()); 1028 1029 if (item_parent != NULL && item_parent->pag()->IDUser == m_me.ID) 1030 message_to_me = true; 1031 1032 while (item_parent != NULL) 1033 { 1034 AMessageInfoGUI* info_parent = item_parent->pag(); 1035 1036 int old_unread_count = info_parent->UnreadChildCount; 1037 int old_unread_count_my = info_parent->UnreadChildCountMy; 1038 1039 // уменьшение количества непрочитанных дочерних 1040 // и установка соответствующих флагов 1041 if (info_parent->UnreadChildCount > 0) 1042 info_parent->UnreadChildCount--; 1043 1044 if (message_to_me == true && info_parent->UnreadChildCountMy > 0) 1045 info_parent->UnreadChildCountMy--; 1046 1047 if (info_parent->UnreadChildCountMy == 0) 1048 info_parent->HasUnreadChildMy = false; 1049 1050 if (info_parent->UnreadChildCount == 0) 1051 info_parent->HasUnreadChild = false; 1052 1053 // установка иконок 1054 if (info_parent->IsRead == false) 1055 { 1056 // родитель непрочитан 1057 1058 // если среди дочерних прочитали дочернее мне и больше непрочитанных дочерних мне нет 1059 // и должна произойти смена иконки 1060 if (old_unread_count_my != 0 && info_parent->UnreadChildCountMy == 0) 1061 item_parent->setIcon(0, m_message_unread); 1062 } 1063 else 1064 { 1065 // родитель прочитан 1066 1067 // если среди дочерних есть непрочитанные мне 1068 // и должна произойти смена иконки 1069 if (old_unread_count_my != info_parent->UnreadChildCountMy && info_parent->UnreadChildCountMy > 0) 1070 item_parent->setIcon(0, m_child_unread_my); 1071 1072 // если среди дочерних есть непрочитанные 1073 // и должна произойти смена иконки 1074 else if (old_unread_count != info_parent->UnreadChildCount && info_parent->UnreadChildCount > 0) 1075 item_parent->setIcon(0, m_child_unread); 1076 1077 // нет дочерних непрочитанных 1078 else 1079 item_parent->setIcon(0, m_message_read); 1080 } 1081 1082 item_parent = static_cast<MessageTreeWidgetItem*>(item_parent->parent()); 1083 } 1084 1085 // уменьшение количества непрочитанных в дереве форума 1086 m_forum_tree->changeUnreadCount(-1); 1087 } 1088 else // if (is_read == true) 1089 { 1090 // TODO: Доделать пометку родителей, если отметилось сообщение, которое является ответом мне 1091 1092 // установка иконки помечаемому сообщению 1093 item->setIcon(0, m_message_unread); 1094 1095 // установка флагов и иконок у родительских сообщений 1096 MessageTreeWidgetItem* parent_item = static_cast<MessageTreeWidgetItem*>(item->parent()); 1097 1098 while (parent_item != NULL) 1099 { 1100 AMessageInfoGUI* parent_info = parent_item->pag(); 1101 1102 // смена иконки при необходимости 1103 if (parent_info->IsRead == true && parent_info->HasUnreadChild == false) 1104 parent_item->setIcon(0, m_child_unread); 1105 1106 parent_info->UnreadChildCount++; 1107 parent_info->HasUnreadChild = true; 1108 1109 parent_item = static_cast<MessageTreeWidgetItem*>(parent_item->parent()); 1110 } 1111 1112 // увеличение количества непрочитанных в дереве форума 1113 m_forum_tree->changeUnreadCount(1); 1114 1115 } // if (is_read == true) ... else 967 1116 } 968 1117 //---------------------------------------------------------------------------------------------- … … 1396 1545 } 1397 1546 //---------------------------------------------------------------------------------------------- 1547 1548 bool AMessageTree::markThreadAsRead (int id, bool is_read) 1549 { 1550 std::auto_ptr<IAStorage> storage(AStorageFactory::getStorage()); 1551 1552 if (storage.get() == NULL) 1553 { 1554 QMessageBox::critical(m_parent, QString::fromUtf8("Ошибка!"), QString::fromUtf8("Не выбрано хранилище данных")); 1555 return false; 1556 } 1557 1558 if (storage->setIDsAsRead(QList<int>() << id, idsTopic, is_read, QDateTime(), NULL) == false) 1559 { 1560 storage->showError(m_parent); 1561 return false; 1562 } 1563 1564 return true; 1565 } 1566 //---------------------------------------------------------------------------------------------- 1567 1568 void AMessageTree::menu_mark_thread_as_read_triggered () 1569 { 1570 QTreeWidgetItem* item = currentItem(); 1571 1572 if (item == NULL) 1573 return; 1574 1575 // поиск родителя 1576 QTreeWidgetItem* parent = static_cast<QTreeWidgetItem*>(ATreeWidgetItem::rootItem(item)); 1577 1578 // пометка в хранилище 1579 if (markThreadAsRead(parent->pag()->ID, true) != true) 1580 return; 1581 1582 // пометка в дереве 1583 markThreadAsRead(parent, true, 1584 } 1585 //---------------------------------------------------------------------------------------------- 1586 1587 void AMessageTree::menu_mark_thread_as_unread_triggered () 1588 { 1589 } 1590 //---------------------------------------------------------------------------------------------- 1591 1592 void AMessageTree::markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count) 1593 { 1594 } 1595 //---------------------------------------------------------------------------------------------- -
branches/message_tree/message_tree.h
r185 r188 153 153 154 154 /*! 155 * \brief Раскрытие дерева элементов до всех непрочитан ых сообщений155 * \brief Раскрытие дерева элементов до всех непрочитанных сообщений 156 156 * \param root Родительский элемент дерева для раскрытия 157 157 */ … … 170 170 */ 171 171 void changeRating (int new_rate); 172 173 /* 174 * \brief Расширенная реализация IMessageTree::gotoNextUnreadArticle 175 * \param item Элемент дерева, относительно которого требуется вести поиск 176 */ 177 void gotoNextUnreadArticle (QTreeWidgetItem* current_item); 178 179 /* 180 * \brief Пометка сообщения как прочитанного/непрочитанного 181 * \param item Элемент дерева 182 * \param is_read Флаг прочитанного 183 */ 184 void markItemAsRead (QTreeWidgetItem* item, bool is_read); 185 186 /* 187 * \brief Пометка ветки как прочитанной/непрочитанной 188 * \param item Элемент дерева 189 * \param is_read Флаг прочитанного 190 * \param count Количество элементов, которые были помечены 191 */ 192 void markThreadAsRead (QTreeWidgetItem* parent, bool is_read, int& count) 193 194 /* 195 * \brief Пометка ветки как прочитанной/непрочитанной в хранилище 196 * \param id ID топика 197 * \param is_read Флаг прочитанного 198 * \return true, если ветка в хранилище помечена 199 */ 200 bool markThreadAsRead (int id, bool is_read); 172 201 173 202 // IMessageTree -
branches/message_tree/model/message.h
r182 r188 74 74 bool IsBodyLoaded; /*!< \brief Загружено ли тело сообщения */ 75 75 bool IsChildLoaded; /*!< \brief Загружены ли дочерние сообщения */ 76 intHasUnreadChild; /*!< \brief Наличие непрочитанных дочерних */77 intHasUnreadChildMy; /*!< \brief Наличие непрочитанных дочерних мне */76 bool HasUnreadChild; /*!< \brief Наличие непрочитанных дочерних */ 77 bool HasUnreadChildMy; /*!< \brief Наличие непрочитанных дочерних мне */ 78 78 int UnreadChildCount; /*!< \brief Количество непрочитанных дочерних */ 79 79 int UnreadChildCountMy; /*!< \brief Количество непрочитанных дочерних мне */ -
branches/message_tree/storage/mysql_storage.cpp
r183 r188 2093 2093 if (id_parent_user > 1) 2094 2094 info->HasUnreadChildMy = true; 2095 else 2096 info->HasUnreadChild = true;2095 2096 info->HasUnreadChild = true; 2097 2097 2098 2098 break; -
branches/message_tree/version.h
r187 r188 20 20 * \brief Дата билда (заменяется автоматически при каждом билде в version.h, что и приводит к смене номера ревизии) 21 21 */ 22 #define AVALON_DATE " Чтв Мар 26 18:55:12MSK 2009"22 #define AVALON_DATE "Птн Мар 27 01:02:25 MSK 2009" 23 23 24 24 #endif
Note: See TracChangeset
for help on using the changeset viewer.
