Changeset 175
- Timestamp:
- 03/23/09 04:03:38 (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
- 2 copied
-
icon_effect.cpp (copied) (copied from trunk/webservice.cpp) (1 diff)
-
icon_effect.h (copied) (copied from trunk/webservice.h) (2 diffs)
-
icons/myunread.png (added)
-
message_tree.cpp (modified) (30 diffs)
-
message_tree.h (modified) (3 diffs)
-
resource.qrc (modified) (1 diff)
-
storage/istorage.h (modified) (2 diffs)
-
storage/mysql_storage.cpp (modified) (9 diffs)
-
storage/mysql_storage.h (modified) (1 diff)
-
sysheaders.h (modified) (1 diff)
-
version.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/icon_effect.cpp
r152 r175 5 5 // $URL$ 6 6 //---------------------------------------------------------------------------------------------- 7 #include "webservice.h" 7 #include "icon_effect.h" 8 //---------------------------------------------------------------------------------------------- 8 9 9 /*! 10 * \brief Возвращает текст между from-to не включая их из строки source 11 * \param source Указатель на исходную строку 12 * \param from Начальный разделитель 13 * \param to Конечный разделитель 14 * \return Строка между разделителями 15 */ 16 QString getTextBetween (const QString* source, const QString& from, const QString& to) 10 QIcon AIconEffect::unionIcons (const QString& file1, const QString& file2) 17 11 { 18 int idx1 = source->indexOf(from); 12 QImage img_1 = QImage(file1); 13 QImage img_2 = QImage(file2); 19 14 20 if (idx1 == -1) 21 return ""; 15 QPainter painter(&img_1); 22 16 23 int idx2 = source->indexOf(to, idx1 + 1);17 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); 24 18 25 if (idx2 == -1) 26 return ""; 19 painter.drawImage(0, 0, img_2); 27 20 28 return source->mid(idx1 + from.length(), idx2 - idx1 - from.length()); 29 } 21 painter.end(); 30 22 31 /*! 32 * \brief Итерация по блокам from-to со сдвигом смещения 33 * \param source Указатель на исходную строку 34 * \param from Начальный разделитель 35 * \param to Конечный разделитель 36 * \param seed Смещение 37 * \return Строка между разделителями 38 */ 39 QString getNextBlock (const QString* source, const QString& from, const QString& to, int& seed) 40 { 41 int idx1 = source->indexOf(from, seed); 42 43 if (idx1 == -1) 44 return ""; 45 46 int idx2 = source->indexOf(to, idx1 + 1); 47 48 if (idx2 == -1) 49 return ""; 50 51 QString result = source->mid(idx1 + from.length(), idx2 - idx1 - from.length()); 52 53 seed = idx2 + to.length(); 54 55 return result; 56 } 57 58 /*! 59 * \brief Преобразование строки в дату/время (требуется в связи с отсчетом времени с начала эпохи UNIX) 60 * \param value Строковое значение даты 61 * \return Объект преобразования 62 */ 63 QDateTime getDateTimeFromString (const QString& value) 64 { 65 if (value == "0001-01-01T00:00:00") 66 return QDateTime::fromString("1970-01-01T00:00:00", Qt::ISODate); 67 68 return QDateTime::fromString(value, Qt::ISODate); 23 return QIcon(QPixmap::fromImage(img_1)); 69 24 } 70 25 //---------------------------------------------------------------------------------------------- 71 72 void AWebservice::getForumList_WebserviceQuery (QString& header, QString& data, IProgress* progress)73 {74 if (progress != NULL)75 progress->onProgress(0);76 77 QSettings settings;78 79 QString rsdn_login = settings.value("rsdn/login", "").toString();80 QString rsdn_password = settings.value("rsdn/password", "").toString();81 82 data = "";83 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";84 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";85 data += " <soap:Body>\r\n";86 data += " <GetForumList xmlns=\"http://rsdn.ru/Janus/\">\r\n";87 data += " <forumRequest>\r\n";88 data += (QString)" <userName>" + rsdn_login + "</userName>\r\n";89 data += (QString)" <password>" + rsdn_password + "</password>\r\n";90 data += " <forumsRowVersion>AAAAAAAAAAA=</forumsRowVersion>\r\n";91 data += " </forumRequest>\r\n";92 data += " </GetForumList>\r\n";93 data += " </soap:Body>\r\n";94 data += "</soap:Envelope>\r\n";95 96 header = "";97 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";98 header += "Host: rsdn.ru\r\n";99 header += "Content-Type: text/xml; charset=utf-8\r\n";100 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";101 header += "SOAPAction: \"http://rsdn.ru/Janus/GetForumList\"\r\n";102 }103 //----------------------------------------------------------------------------------------------104 105 void AWebservice::getForumList_WebserviceParse (const QString& data, AForumGroupInfoList& list, IProgress* progress)106 {107 if (progress != NULL)108 progress->onProgress(0);109 110 list.clear();111 112 //113 // список групп форумов114 //115 116 AGroupInfoList group_list;117 118 int seed = 0;119 120 QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);121 122 while (group_info.length())123 {124 AGroupInfo info;125 126 info.ID = getTextBetween(&group_info, "<forumGroupId>", "</forumGroupId>").toInt();127 info.Name = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>");128 info.SortOrder = getTextBetween(&group_info, "<sortOrder>", "</sortOrder>").toInt();129 130 group_list.append(info);131 132 group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);133 }134 135 //136 // список форумов137 //138 139 AForumInfoList forum_list;140 141 seed = 0;142 143 QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);144 145 while (forum_info.length())146 {147 AForumInfo info;148 149 info.ID = getTextBetween(&forum_info, "<forumId>", "</forumId>").toInt();150 info.IDGroup = getTextBetween(&forum_info, "<forumGroupId>", "</forumGroupId>").toInt();151 info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>");152 info.Name = getTextBetween(&forum_info, "<forumName>", "</forumName>");153 info.Rated = getTextBetween(&forum_info, "<rated>", "</rated>").toInt();154 info.InTop = getTextBetween(&forum_info, "<inTop>", "</inTop>").toInt();155 info.RateLimit = getTextBetween(&forum_info, "<rateLimit>", "</rateLimit>").toInt();156 157 forum_list.append(info);158 159 forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);160 }161 162 //163 // заполнение результата164 //165 166 for (int group_index = 0; group_index < group_list.count(); group_index++)167 {168 AForumGroupInfo group_info;169 170 group_info.Group = group_list[group_index];171 172 for (int forum_index = 0; forum_index < forum_list.count(); forum_index++)173 if (forum_list[forum_index].IDGroup == group_info.Group.ID)174 group_info.Forums.append(forum_list[forum_index]);175 176 list.append(group_info);177 }178 179 //180 // добавление "мусорки"181 //182 183 /*184 AForumGroupInfo trash_group;185 186 trash_group.Group.ID = 0;187 trash_group.Group.Name = QString::fromUtf8("Корзина");188 trash_group.Group.SortOrder = 10000;189 190 AForumInfo trash_forum;191 192 trash_forum.ID = 0;193 trash_forum.IDGroup = 0;194 trash_forum.ShortName = "trash";195 trash_forum.Name = QString::fromUtf8("Удаленные");196 trash_forum.Rated = true;197 trash_forum.InTop = true;198 trash_forum.RateLimit = 0;199 200 trash_group.Forums.append(trash_forum);201 202 list.append(trash_group);203 */204 }205 //----------------------------------------------------------------------------------------------206 207 void AWebservice::getUserList_WebserviceQuery (QString& header, QString& data, const QString& row_version, IProgress* progress)208 {209 if (progress != NULL)210 progress->onProgress(0);211 212 QSettings settings;213 214 QString rsdn_login = settings.value("rsdn/login", "").toString();215 QString rsdn_password = settings.value("rsdn/password", "").toString();216 217 data = "";218 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";219 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";220 data += " <soap:Body>\r\n";221 data += " <GetNewUsers xmlns=\"http://rsdn.ru/Janus/\">\r\n";222 data += " <userRequest>\r\n";223 data += (QString)" <userName>" + rsdn_login + "</userName>\r\n";224 data += (QString)" <password>" + rsdn_password + "</password>\r\n";225 data += (QString)" <lastRowVersion>" + row_version + "</lastRowVersion>\r\n";226 data += " <maxOutput>0</maxOutput>\r\n";227 data += " </userRequest>\r\n";228 data += " </GetNewUsers>\r\n";229 data += " </soap:Body>\r\n";230 data += "</soap:Envelope>\r\n";231 232 header = "";233 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";234 header += "Host: rsdn.ru\r\n";235 header += "Content-Type: text/xml; charset=utf-8\r\n";236 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";237 header += "SOAPAction: \"http://rsdn.ru/Janus/GetNewUsers\"\r\n";238 }239 //----------------------------------------------------------------------------------------------240 241 void AWebservice::getUserList_WebserviceParse (const QString& data, AUserInfoList& list, QString& row_version, IProgress* progress)242 {243 if (progress != NULL)244 progress->onProgress(0);245 246 list.clear();247 248 row_version = "";249 250 int seed = 0;251 252 QString user_info = getNextBlock(&data, "<JanusUserInfo>", "</JanusUserInfo>", seed);253 254 while (user_info.length())255 {256 AUserInfo info;257 258 info.ID = getTextBetween(&user_info, "<userId>", "</userId>").toInt();259 info.Name = getTextBetween(&user_info, "<userName>", "</userName>");260 info.Nick = getTextBetween(&user_info, "<userNick>", "</userNick>");261 info.RealName = getTextBetween(&user_info, "<realName>", "</realName>");262 info.Email = getTextBetween(&user_info, "<publicEmail>", "</publicEmail>");263 info.Homepage = getTextBetween(&user_info, "<homePage>", "</homePage>");264 info.Specialization = getTextBetween(&user_info, "<specialization>", "</specialization>");265 info.WhereFrom = getTextBetween(&user_info, "<whereFrom>", "</whereFrom>");266 info.Origin = getTextBetween(&user_info, "<origin>", "</origin>");267 268 list.append(info);269 270 user_info = getNextBlock(&data, "<JanusUserInfo>", "</JanusUserInfo>", seed);271 }272 273 seed = 0;274 row_version = getNextBlock(&data, "<lastRowVersion>", "</lastRowVersion>", seed);275 276 if (row_version.length() == 0)277 row_version = "AAAAAAAAAAA=";278 }279 //----------------------------------------------------------------------------------------------280 281 void AWebservice::getMessageList_WebserviceQuery (QString& header, QString& data, const ARowVersion& row_version, const ADataQuery& query, IProgress* progress)282 {283 if (progress != NULL)284 progress->onProgress(0);285 286 QSettings settings;287 288 QString rsdn_login = settings.value("rsdn/login", "").toString();289 QString rsdn_password = settings.value("rsdn/password", "").toString();290 291 data = "";292 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";293 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";294 data += " <soap:Body>\r\n";295 data += " <GetNewData xmlns=\"http://rsdn.ru/Janus/\">\r\n";296 data += " <changeRequest>\r\n";297 data += (QString)" <userName>" + rsdn_login + "</userName>\r\n";298 data += (QString)" <password>" + rsdn_password + "</password>\r\n";299 300 // подписанные форумы301 if (query.Forum.count() > 0)302 {303 data += " <subscribedForums>\r\n";304 305 for (int i = 0; i < query.Forum.count(); i++)306 {307 data += " <RequestForumInfo>\r\n";308 data += (QString)" <forumId>" + QString::number(query.Forum[i].IDForum) + "</forumId>\r\n";309 data += (QString)" <isFirstRequest>" + (query.Forum[i].IsFirst ? "true" : "false") + "</isFirstRequest>\r\n";310 data += " </RequestForumInfo>\r\n";311 }312 313 data += " </subscribedForums>\r\n";314 }315 else316 data += " <subscribedForums />\r\n";317 318 // версии319 data += (QString)" <ratingRowVersion>" + row_version.Rating + "</ratingRowVersion>\r\n";320 data += (QString)" <messageRowVersion>" + row_version.Message + "</messageRowVersion>\r\n";321 data += (QString)" <moderateRowVersion>" + row_version.Moderate + "</moderateRowVersion>\r\n";322 323 // ID оборванных сообщений, то есть сообщений без родителя.324 if (query.BrokenMessage.count() > 0)325 {326 data += " <breakMsgIds>\r\n";327 328 for (int i = 0; i < query.BrokenMessage.count(); i++)329 data += (QString)" <int>" + QString::number(query.BrokenMessage[i]) + "</int>\r\n";330 331 data += " </breakMsgIds>\r\n";332 }333 else334 data += " <breakMsgIds />\r\n";335 336 // ID топика не имеющего корневого сообщения или просто ID топика, который хочется выкачать целиком337 // topicId == messageId первого сообщения топика338 if (query.BrokenTopic.count() > 0)339 {340 data += " <breakTopicIds>\r\n";341 342 for (int i = 0; i < query.BrokenTopic.count(); i++)343 data += (QString)" <int>" + QString::number(query.BrokenTopic[i]) + "</int>\r\n";344 345 data += " </breakTopicIds>\r\n";346 }347 else348 data += " <breakTopicIds />\r\n";349 350 data += " <maxOutput>0</maxOutput>\r\n";351 data += " </changeRequest>\r\n";352 data += " </GetNewData>\r\n";353 data += " </soap:Body>\r\n";354 data += "</soap:Envelope>\r\n";355 356 header = "";357 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";358 header += "Host: rsdn.ru\r\n";359 header += "Content-Type: text/xml; charset=utf-8\r\n";360 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";361 header += "SOAPAction: \"http://rsdn.ru/Janus/GetNewData\"\r\n";362 }363 //----------------------------------------------------------------------------------------------364 365 QString AWebservice::getMessageList_WebserviceParse (const QString& data, ADataList& list, ARowVersion& row_version, IProgress* progress)366 {367 if (progress != NULL)368 progress->onProgress(0);369 370 list.Rating.clear();371 list.Message.clear();372 list.Moderate.clear();373 374 int seed = 0;375 376 QString message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);377 378 while (message_info.length())379 {380 AMessageInfo info;381 382 info.ID = getTextBetween(&message_info, "<messageId>", "</messageId>").toInt();383 info.IDTopic = getTextBetween(&message_info, "<topicId>", "</topicId>").toInt();384 info.IDParent = getTextBetween(&message_info, "<parentId>", "</parentId>").toInt();385 info.IDUser = getTextBetween(&message_info, "<userId>", "</userId>").toInt();386 info.IDForum = getTextBetween(&message_info, "<forumId>", "</forumId>").toInt();387 info.Subject = getTextBetween(&message_info, "<subject>", "</subject>");388 info.MessageName = getTextBetween(&message_info, "<messageName>", "</messageName>");389 info.UserNick = getTextBetween(&message_info, "<userNick>", "</userNick>");390 info.Message = getTextBetween(&message_info, "<message>", "</message>");391 info.IDArticle = getTextBetween(&message_info, "<articleId>", "</articleId>").toInt();392 info.MessageDate = getDateTimeFromString(getTextBetween(&message_info, "<messageDate>", "</messageDate>"));393 info.UpdateDate = getDateTimeFromString(getTextBetween(&message_info, "<updateDate>", "</updateDate>"));394 info.UserRole = getTextBetween(&message_info, "<userRole>", "</userRole>");395 info.UserTitle = getTextBetween(&message_info, "<userTitle>", "</userTitle>");396 info.UserTitleColor = getTextBetween(&message_info, "<userTitleColor>", "</userTitleColor>").toInt();397 info.LastModerated = getDateTimeFromString(getTextBetween(&message_info, "<lastModerated>", "</lastModerated>"));398 399 if (info.MessageDate.isValid() == false)400 return QString::fromUtf8("Некорректное значение даты <messageDate>: ") + getTextBetween(&message_info, "<messageDate>", "</messageDate>");401 402 if (info.UpdateDate.isValid() == false)403 return QString::fromUtf8("Некорректное значение даты <updateDate>: ") + getTextBetween(&message_info, "<updateDate>", "</updateDate>");404 405 if (info.LastModerated.isValid() == false)406 return QString::fromUtf8("Некорректное значение даты <lastModerated>: ") + getTextBetween(&message_info, "<lastModerated>", "</lastModerated>");407 408 list.Message.append(info);409 410 message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);411 }412 413 seed = 0;414 415 QString rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);416 417 while (rating_info.length())418 {419 ARatingInfo info;420 421 info.IDMessage = getTextBetween(&rating_info, "<messageId>", "</messageId>").toInt();422 info.IDTopic = getTextBetween(&rating_info, "<topicId>", "</topicId>").toInt();423 info.IDUser = getTextBetween(&rating_info, "<userId>", "</userId>").toInt();424 info.UserRating = getTextBetween(&rating_info, "<userRating>", "</userRating>").toInt();425 info.Rate = getTextBetween(&rating_info, "<rate>", "</rate>").toInt();426 info.RateDate = getDateTimeFromString(getTextBetween(&rating_info, "<rateDate>", "</rateDate>"));427 428 if (info.RateDate.isValid() == false)429 return QString::fromUtf8("Некорректное значение даты <rateDate>: ") + getTextBetween(&rating_info, "<rateDate>", "</rateDate>");430 431 list.Rating.append(info);432 433 rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);434 }435 436 seed = 0;437 438 QString moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);439 440 while (moderate_info.length())441 {442 AModerateInfo info;443 444 info.IDMessage = getTextBetween(&moderate_info, "<messageId>", "</messageId>").toInt();445 // TODO: пропущен <topicId>int</topicId> (похоже по невнимательности, ну да он и не особо нужен пока что)446 info.IDUser = getTextBetween(&moderate_info, "<userId>", "</userId>").toInt();447 info.IDForum = getTextBetween(&moderate_info, "<forumId>", "</forumId>").toInt();448 info.Created = getDateTimeFromString(getTextBetween(&moderate_info, "<create>", "</create>"));449 450 if (info.Created.isValid() == false)451 return QString::fromUtf8("Некорректное значение даты <create>: ") + getTextBetween(&moderate_info, "<create>", "</create>");452 453 list.Moderate.append(info);454 455 moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);456 }457 458 seed = 0;459 row_version.Rating = getNextBlock(&data, "<lastRatingRowVersion>", "</lastRatingRowVersion>", seed);460 seed = 0;461 row_version.Message = getNextBlock(&data, "<lastForumRowVersion>", "</lastForumRowVersion>", seed);462 seed = 0;463 row_version.Moderate = getNextBlock(&data, "<lastModerateRowVersion>", "</lastModerateRowVersion>", seed);464 465 if (row_version.Rating.length() == 0)466 row_version.Rating = "AAAAAAAAAAA=";467 if (row_version.Message.length() == 0)468 row_version.Message = "AAAAAAAAAAA=";469 if (row_version.Moderate.length() == 0)470 row_version.Moderate = "AAAAAAAAAAA=";471 472 return "";473 }474 //----------------------------------------------------------------------------------------------475 476 void AWebservice::getMessageListByID_WebserviceQuery (QString& header, QString& data, const QList<int> ids, IProgress* progress)477 {478 if (progress != NULL)479 progress->onProgress(0);480 481 QSettings settings;482 483 QString rsdn_login = settings.value("rsdn/login", "").toString();484 QString rsdn_password = settings.value("rsdn/password", "").toString();485 486 data = "";487 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";488 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";489 data += " <soap:Body>\r\n";490 data += " <GetTopicByMessage xmlns=\"http://rsdn.ru/Janus/\">\r\n";491 data += " <topicRequest>\r\n";492 data += (QString)" <userName>" + rsdn_login + "</userName>\r\n";493 data += (QString)" <password>" + rsdn_password + "</password>\r\n";494 495 // ID оборванных сообщений, то есть сообщений без родителя.496 if (ids.count() > 0)497 {498 data += " <messageIds>\r\n";499 500 for (int i = 0; i < ids.count(); i++)501 data += (QString)" <int>" + QString::number(ids[i]) + "</int>\r\n";502 503 data += " </messageIds>\r\n";504 }505 else506 data += " <messageIds />\r\n";507 508 data += " </topicRequest>\r\n";509 data += " </GetTopicByMessage>\r\n";510 data += " </soap:Body>\r\n";511 data += "</soap:Envelope>\r\n";512 513 header = "";514 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";515 header += "Host: rsdn.ru\r\n";516 header += "Content-Type: text/xml; charset=utf-8\r\n";517 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";518 header += "SOAPAction: \"http://rsdn.ru/Janus/GetTopicByMessage\"\r\n";519 }520 //----------------------------------------------------------------------------------------------521 522 QString AWebservice::getMessageListByID_WebserviceParse (const QString& data, ADataList& list, IProgress* progress)523 {524 if (progress != NULL)525 progress->onProgress(0);526 527 list.Rating.clear();528 list.Message.clear();529 list.Moderate.clear();530 531 int seed = 0;532 533 QString message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);534 535 while (message_info.length())536 {537 AMessageInfo info;538 539 info.ID = getTextBetween(&message_info, "<messageId>", "</messageId>").toInt();540 info.IDTopic = getTextBetween(&message_info, "<topicId>", "</topicId>").toInt();541 info.IDParent = getTextBetween(&message_info, "<parentId>", "</parentId>").toInt();542 info.IDUser = getTextBetween(&message_info, "<userId>", "</userId>").toInt();543 info.IDForum = getTextBetween(&message_info, "<forumId>", "</forumId>").toInt();544 info.Subject = getTextBetween(&message_info, "<subject>", "</subject>");545 info.MessageName = getTextBetween(&message_info, "<messageName>", "</messageName>");546 info.UserNick = getTextBetween(&message_info, "<userNick>", "</userNick>");547 info.Message = getTextBetween(&message_info, "<message>", "</message>");548 info.IDArticle = getTextBetween(&message_info, "<articleId>", "</articleId>").toInt();549 info.MessageDate = getDateTimeFromString(getTextBetween(&message_info, "<messageDate>", "</messageDate>"));550 info.UpdateDate = getDateTimeFromString(getTextBetween(&message_info, "<updateDate>", "</updateDate>"));551 info.UserRole = getTextBetween(&message_info, "<userRole>", "</userRole>");552 info.UserTitle = getTextBetween(&message_info, "<userTitle>", "</userTitle>");553 info.UserTitleColor = getTextBetween(&message_info, "<userTitleColor>", "</userTitleColor>").toInt();554 info.LastModerated = getDateTimeFromString(getTextBetween(&message_info, "<lastModerated>", "</lastModerated>"));555 556 if (info.MessageDate.isValid() == false)557 return QString::fromUtf8("Некорректное значение даты <messageDate>: ") + getTextBetween(&message_info, "<messageDate>", "</messageDate>");558 559 if (info.UpdateDate.isValid() == false)560 return QString::fromUtf8("Некорректное значение даты <updateDate>: ") + getTextBetween(&message_info, "<updateDate>", "</updateDate>");561 562 if (info.LastModerated.isValid() == false)563 return QString::fromUtf8("Некорректное значение даты <lastModerated>: ") + getTextBetween(&message_info, "<lastModerated>", "</lastModerated>");564 565 list.Message.append(info);566 567 message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed);568 }569 570 seed = 0;571 572 QString rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);573 574 while (rating_info.length())575 {576 ARatingInfo info;577 578 info.IDMessage = getTextBetween(&rating_info, "<messageId>", "</messageId>").toInt();579 info.IDTopic = getTextBetween(&rating_info, "<topicId>", "</topicId>").toInt();580 info.IDUser = getTextBetween(&rating_info, "<userId>", "</userId>").toInt();581 info.UserRating = getTextBetween(&rating_info, "<userRating>", "</userRating>").toInt();582 info.Rate = getTextBetween(&rating_info, "<rate>", "</rate>").toInt();583 info.RateDate = getDateTimeFromString(getTextBetween(&rating_info, "<rateDate>", "</rateDate>"));584 585 if (info.RateDate.isValid() == false)586 return QString::fromUtf8("Некорректное значение даты <rateDate>: ") + getTextBetween(&rating_info, "<rateDate>", "</rateDate>");587 588 list.Rating.append(info);589 590 rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed);591 }592 593 seed = 0;594 595 QString moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);596 597 while (moderate_info.length())598 {599 AModerateInfo info;600 601 info.IDMessage = getTextBetween(&moderate_info, "<messageId>", "</messageId>").toInt();602 info.IDUser = getTextBetween(&moderate_info, "<userId>", "</userId>").toInt();603 info.IDForum = getTextBetween(&moderate_info, "<forumId>", "</forumId>").toInt();604 info.Created = getDateTimeFromString(getTextBetween(&moderate_info, "<create>", "</create>"));605 606 if (info.Created.isValid() == false)607 return QString::fromUtf8("Некорректное значение даты <create>: ") + getTextBetween(&moderate_info, "<create>", "</create>");608 609 list.Moderate.append(info);610 611 moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed);612 }613 614 return "";615 }616 //----------------------------------------------------------------------------------------------617 618 void AWebservice::postChange_WebserviceQuery (QString& header, QString& data, const AMessage2SendList& list_messages, const ARating2SendList& list_rating, const AModerate2SendList& list_moderate, IProgress* progress)619 {620 if (progress != NULL)621 progress->onProgress(0);622 623 QSettings settings;624 625 QString rsdn_login = settings.value("rsdn/login", "").toString();626 QString rsdn_password = settings.value("rsdn/password", "").toString();627 628 data = "";629 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";630 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";631 data += " <soap:Body>\r\n";632 data += " <PostChange xmlns=\"http://rsdn.ru/Janus/\">\r\n";633 data += " <postRequest>\r\n";634 data += (QString)" <userName>" + rsdn_login + "</userName>\r\n";635 data += (QString)" <password>" + rsdn_password + "</password>\r\n";636 637 // сообщения638 if (list_messages.count() > 0)639 {640 data += " <writedMessages>\r\n";641 642 for (int i = 0; i < list_messages.count(); i++)643 {644 QString message = list_messages[i].Message;645 646 QString subject = list_messages[i].Subject;647 648 subject.replace("&", "&");649 subject.replace("<", "<");650 subject.replace(">", ">");651 652 data += " <PostMessageInfo>\r\n";653 data += (QString)" <localMessageId>" + QString::number(list_messages[i].ID) + "</localMessageId>\r\n";654 data += (QString)" <parentId>" + QString::number(list_messages[i].IDParent) + "</parentId>\r\n";655 data += (QString)" <forumId>" + QString::number(list_messages[i].IDForum) + "</forumId>\r\n";656 data += (QString)" <subject>" + subject + "</subject>\r\n";657 data += (QString)" <message>" + message + "</message>\r\n";658 data += " </PostMessageInfo>\r\n";659 }660 661 data += " </writedMessages>\r\n";662 }663 else664 data += " <writedMessages />\r\n";665 666 // рейтинги667 if (list_rating.count() > 0)668 {669 data += " <rates>\r\n";670 671 for (int i = 0; i < list_rating.count(); i++)672 {673 data += " <PostRatingInfo>\r\n";674 data += (QString)" <localRatingId>" + QString::number(list_rating[i].ID) + "</localRatingId>\r\n";675 data += (QString)" <messageId>" + QString::number(list_rating[i].IDMessage) + "</messageId>\r\n";676 data += (QString)" <rate>" + QString::number(list_rating[i].Rate) + "</rate>\r\n";677 data += " </PostRatingInfo>\r\n";678 }679 680 data += " </rates>\r\n";681 }682 else683 data += " <rates />\r\n";684 685 // модерилки686 if (list_moderate.count() > 0)687 {688 data += " <moderates>\r\n";689 690 for (int i = 0; i < list_moderate.count(); i++)691 {692 QString description = list_moderate[i].Description;693 694 description.replace("&", "&");695 description.replace("<", "<");696 description.replace(">", ">");697 698 data += " <PostModerateInfo>\r\n";699 data += (QString)" <LocalModerateId>" + QString::number(list_moderate[i].ID) + "</LocalModerateId>\r\n";700 data += (QString)" <MessageId>" + QString::number(list_moderate[i].IDMessage) + "</MessageId>\r\n";701 data += (QString)" <ModerateAction>" + list_moderate[i].Action + "</ModerateAction>\r\n";702 data += (QString)" <ModerateToForumId>" + QString::number(list_moderate[i].IDForum) + "</ModerateToForumId>\r\n";703 data += (QString)" <Description>" + description + "</Description>\r\n";704 data += (QString)" <AsModerator>" + QString::number(list_moderate[i].AsModerator) + "</AsModerator>\r\n";705 data += " </PostModerateInfo>\r\n";706 }707 708 data += " </moderates>\r\n";709 }710 else711 data += " <moderates />\r\n";712 713 data += " </postRequest>\r\n";714 data += " </PostChange>\r\n";715 data += " </soap:Body>\r\n";716 data += "</soap:Envelope>\r\n";717 718 header = "";719 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";720 header += "Host: rsdn.ru\r\n";721 header += "Content-Type: text/xml; charset=utf-8\r\n";722 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";723 header += "SOAPAction: \"http://rsdn.ru/Janus/PostChange\"\r\n";724 }725 //----------------------------------------------------------------------------------------------726 727 QString AWebservice::postChange_WebserviceParse (const QString& header, QString& cookie, IProgress* progress)728 {729 if (progress != NULL)730 progress->onProgress(0);731 732 QStringList list = header.split("\r\n");733 734 for (int i = 0; i < list.count(); i++)735 if (list[i].indexOf("Set-Cookie: ") == 0)736 {737 QString cookie_string = list[i];738 739 cookie_string.replace("Set-Cookie: ", "");740 741 QStringList cookie_list = cookie_string.split(";");742 743 if (cookie_list.count() > 1)744 {745 QStringList key_value = cookie_list[0].split("=");746 747 if (key_value.count() != 2)748 continue;749 750 QString key = key_value[0];751 QString value = key_value[1];752 753 cookie += key + "=" + value + "; ";754 }755 }756 757 // убираем "; "758 if (cookie.length() > 0)759 cookie.chop(2);760 761 return "";762 }763 //----------------------------------------------------------------------------------------------764 765 void AWebservice::postChangeCommit_WebserviceQuery (QString& header, QString& data, const QString& cookie, IProgress* progress)766 {767 if (progress != NULL)768 progress->onProgress(0);769 770 QSettings settings;771 772 QString rsdn_login = settings.value("rsdn/login", "").toString();773 QString rsdn_password = settings.value("rsdn/password", "").toString();774 775 data = "";776 data += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";777 data += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";778 data += " <soap:Body>\r\n";779 data += " <PostChangeCommit xmlns=\"http://rsdn.ru/Janus/\" />\r\n";780 data += " </soap:Body>\r\n";781 data += "</soap:Envelope>\r\n";782 783 header = "";784 header += "POST /ws/janusAT.asmx HTTP/1.1\r\n";785 header += "Host: rsdn.ru\r\n";786 header += "Content-Type: text/xml; charset=utf-8\r\n";787 header += (QString)"Content-Length: " + QString::number(data.length()) + "\r\n";788 header += "SOAPAction: \"http://rsdn.ru/Janus/PostChangeCommit\"\r\n";789 790 if (cookie.length() > 0)791 header += "Cookie: " + cookie + "\r\n";792 }793 //----------------------------------------------------------------------------------------------794 795 QString AWebservice::postChangeCommit_WebserviceParse (const QString& data, ACommitInfo& commit_info, IProgress* progress)796 {797 if (progress != NULL)798 progress->onProgress(0);799 800 int seed = 0;801 802 QString messages = getTextBetween(&data, "<commitedIds>", "</commitedIds>");803 804 QString id_info = getNextBlock(&messages, "<int>", "</int>", seed);805 806 while (id_info.length())807 {808 commit_info.Messages.append(id_info.toInt());809 810 id_info = getNextBlock(&messages, "<int>", "</int>", seed);811 }812 813 seed = 0;814 815 QString message_exceptions = getTextBetween(&data, "<exceptions>", "</exceptions>");816 817 QString message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed);818 819 while (message_exception_info.length())820 {821 ACommitExceptionInfo info;822 823 info.Exception = getTextBetween(&message_exception_info, "<exception>", "</exception>");824 info.ID = getTextBetween(&message_exception_info, "<localMessageId>", "</localMessageId>").toInt();825 info.Info = getTextBetween(&message_exception_info, "<info>", "</info>");826 827 commit_info.MessagesExceptions.append(info);828 829 message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed);830 }831 832 seed = 0;833 834 QString ratings = getTextBetween(&data, "<commitedRatingIds>", "</commitedRatingIds>");835 836 id_info = getNextBlock(&ratings, "<int>", "</int>", seed);837 838 while (id_info.length())839 {840 commit_info.Rating.append(id_info.toInt());841 842 id_info = getNextBlock(&ratings, "<int>", "</int>", seed);843 }844 845 seed = 0;846 847 QString rating_exceptions = getTextBetween(&data, "<ratingExceptions>", "</ratingExceptions>");848 849 QString rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed);850 851 while (rating_exception_info.length())852 {853 ACommitExceptionInfo info;854 855 info.Exception = getTextBetween(&rating_exception_info, "<exception>", "</exception>");856 info.ID = getTextBetween(&rating_exception_info, "<localRatingId>", "</localRatingId>").toInt();857 info.Info = getTextBetween(&rating_exception_info, "<info>", "</info>");858 859 commit_info.RatingExceptions.append(info);860 861 rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed);862 }863 864 seed = 0;865 866 QString moderates = getTextBetween(&data, "<commitedModerateIds>", "</commitedModerateIds>");867 868 id_info = getNextBlock(&moderates, "<int>", "</int>", seed);869 870 while (id_info.length())871 {872 commit_info.Moderate.append(id_info.toInt());873 874 id_info = getNextBlock(&moderates, "<int>", "</int>", seed);875 }876 877 seed = 0;878 879 QString moderate_exceptions = getTextBetween(&data, "<moderateExceptions>", "</moderateExceptions>");880 881 QString moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed);882 883 while (rating_exception_info.length())884 {885 ACommitExceptionInfo info;886 887 info.Exception = getTextBetween(&moderate_exception_info, "<exception>", "</exception>");888 info.ID = getTextBetween(&moderate_exception_info, "<localRatingId>", "</localRatingId>").toInt();889 info.Info = getTextBetween(&moderate_exception_info, "<info>", "</info>");890 891 commit_info.MessagesExceptions.append(info);892 893 moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed);894 }895 896 return "";897 }898 //---------------------------------------------------------------------------------------------- -
trunk/icon_effect.h
r123 r175 1 1 /*! 2 2 * \file 3 * \brief Класс для работы с вебсервисами RSDN 4 * 3 * \brief Класс для работы эффектами иконок 5 4 * $Date$ 6 5 * $Author$ … … 9 8 */ 10 9 11 #ifndef _avalon_ webservice_h_12 #define _avalon_ webservice_h_10 #ifndef _avalon_icon_effect_h_ 11 #define _avalon_icon_effect_h_ 13 12 14 #include "iprogress.h" 15 #include "model/all.h" 13 #include "sysheaders.h" 16 14 17 15 /*! 18 * \brief Класс для работы с вебсервисами RSDN16 * \brief Класс для работы эффектами иконок 19 17 */ 20 class A Webservice18 class AIconEffect 21 19 { 22 20 public: 23 21 24 22 /*! 25 * \brief Возвращает заголовок и данные для POST запроса получения списка форумов26 * \param header Заголовок HTTP запроса27 * \param data Данные для POST запроса28 * \ param progress Прогресс23 * \brief Объединение 2-х иконок 24 * \param file1 Иконка-подложка 25 * \param file2 Иконка-наложение 26 * \return Иконка с наложением 29 27 */ 30 static void getForumList_WebserviceQuery (QString& header, QString& data, IProgress* progress = NULL); 31 32 /*! 33 * \brief Парсит ответ со списком форумов и заносит результат в список 34 * \param data Строка с данными HTTP ответа 35 * \param list Список групп/форумов 36 * \param progress Прогресс 37 */ 38 static void getForumList_WebserviceParse (const QString& data, AForumGroupInfoList& list, IProgress* progress = NULL); 39 40 /*! 41 * \brief Возвращает заголовок и данные для POST запроса получения списка форумов 42 * \param header Заголовок HTTP запроса 43 * \param data Данные для POST запроса 44 * \param last_row_version Версия строк (снимка) 45 * \param progress Прогресс 46 */ 47 static void getUserList_WebserviceQuery (QString& header, QString& data, const QString& last_row_version, IProgress* progress = NULL); 48 49 /*! 50 * \brief Парсит ответ со списком пользователей и заносит результат в список 51 * \param data Строка с данными HTTP ответа 52 * \param list Список пользователей 53 * \param row_version Версия строк (снимка) 54 * \param progress Прогресс 55 */ 56 static void getUserList_WebserviceParse (const QString& data, AUserInfoList& list, QString& row_version, IProgress* progress = NULL); 57 58 /*! 59 * \brief Возвращает заголовок и данные для POST запроса получения списка сообщений 60 * \param header Заголовок HTTP запроса 61 * \param data Данные для POST запроса 62 * \param row_version Версия строк (снимка) 63 * \param query Описатель запроса данных (поломанные топики, сообщения на докачку, список форумов) 64 * \param progress Прогресс 65 */ 66 static void getMessageList_WebserviceQuery (QString& header, QString& data, const ARowVersion& row_version, const ADataQuery& query, IProgress* progress = NULL); 67 68 /*! 69 * \brief Парсит ответ со списком сообщений и заносит результат в список 70 * \param data Строка с данными HTTP ответа 71 * \param list Список сообщений 72 * \param row_version Версия строк (снимка) 73 * \param progress Прогресс 74 * \return Пустая строка, или сообщение об ошибке 75 */ 76 static QString getMessageList_WebserviceParse (const QString& data, ADataList& list, ARowVersion& row_version, IProgress* progress = NULL); 77 78 /*! 79 * \deprecated Использовался для тестирования работы MySQL с большой (~5GB) базой сообщений, для чего пришлось выкачать все сообщения RSDN 80 * \brief Возвращает заголовок и данные для POST запроса получения списка сообщений 81 * \param header Заголовок HTTP запроса 82 * \param data Данные для POST запроса 83 * \param ids ID сообщений для получения 84 * \param progress Прогресс 85 */ 86 static void getMessageListByID_WebserviceQuery (QString& header, QString& data, const QList<int> ids, IProgress* progress = NULL); 87 88 /*! 89 * \deprecated Использовался для тестирования работы MySQL с большой (~5GB) базой сообщений, для чего пришлось выкачать все сообщения RSDN 90 * \brief Парсит ответ со списком сообщений и заносит результат в список 91 * \param data Строка с данными HTTP ответа 92 * \param list Список сообщений 93 * \param progress Прогресс 94 * \return Пустая строка, или сообщение об ошибке 95 */ 96 static QString getMessageListByID_WebserviceParse (const QString& data, ADataList& list, IProgress* progress = NULL); 97 98 /*! 99 * \brief Возвращает заголовок и данные для POST запроса отправки данных 100 * \param header Заголовок HTTP запроса 101 * \param data Данные для POST запроса 102 * \param list_messages Список сообщений к отправке 103 * \param list_rating Список рейтингов к отправке 104 * \param list_moderate Список модерилок к отправке 105 * \param progress Прогресс 106 */ 107 static void postChange_WebserviceQuery (QString& header, QString& data, const AMessage2SendList& list_messages, const ARating2SendList& list_rating, const AModerate2SendList& list_moderate, IProgress* progress = NULL); 108 109 /*! 110 * \brief Парсит ответ отправки данных и возвращает куку для сессии 111 * \param header Строка с данными HTTP заголовка ответа 112 * \param cookie Кука 113 * \param progress Прогресс 114 * \return Пустая строка, или сообщение об ошибке 115 */ 116 static QString postChange_WebserviceParse (const QString& header, QString& cookie, IProgress* progress = NULL); 117 118 /*! 119 * \brief Возвращает заголовок и данные для POST запроса коммита данных 120 * \param header Заголовок HTTP запроса 121 * \param data Данные для POST запроса 122 * \param cookie Кука 123 * \param progress Прогресс 124 */ 125 static void postChangeCommit_WebserviceQuery (QString& header, QString& data, const QString& cookie, IProgress* progress = NULL); 126 127 /*! 128 * \brief Парсит ответ со списком закоммиченых данных и заносит результат в список 129 * \param data Строка с данными HTTP ответа 130 * \param commit_info Описатель результата коммита 131 * \param progress Прогресс 132 * \return Пустая строка, или сообщение об ошибке 133 */ 134 static QString postChangeCommit_WebserviceParse (const QString& data, ACommitInfo& commit_info, IProgress* progress = NULL); 28 static QIcon unionIcons (const QString& file1, const QString& file2); 135 29 }; 136 30 -
trunk/message_tree.cpp
r171 r175 8 8 #include "global.h" 9 9 #include "model/all.h" 10 #include "icon_effect.h" 10 11 #include "form_source.h" 11 12 #include "form_message.h" … … 23 24 bool IsInfoLoaded; /*!< \brief Флаг наличия загрузки информации (актуально только для топиков) */ 24 25 bool IsChildLoaded; /*!< \brief Флаг того, что загружены дочерние сообщения (актуально только для топиков) */ 25 bool HasUnreadChild; /*!< \brief Флаг наличия непрочитаных дочерних сообщений (актуально только для топиков) */26 26 int UnreadChildCount; /*!< \brief Количество непрочитанных дочерних сообщений */ 27 27 bool IsBodyLoaded; /*!< \brief Загружено ли тело сообщения */ … … 43 43 m_id_group = 0; 44 44 m_id_forum = 0; 45 m_me.ID = -1; 45 46 46 47 setFrameShadow(QFrame::Plain); … … 62 63 m_child_unread = QIcon(":/icons/childunread.png"); 63 64 m_message_unread = QIcon(":/icons/messageunread.png"); 65 66 m_child_unread_my = AIconEffect::unionIcons(":/icons/childunread.png", ":/icons/myunread.png"); 67 m_message_unread_my = AIconEffect::unionIcons(":/icons/messageunread.png", ":/icons/myunread.png"); 64 68 65 69 m_rating_plus_1 = QIcon(":/icons/rate_plus_1.png"); … … 295 299 m_id_group = 0; 296 300 m_id_forum = 0; 301 m_me.ID = -1; 297 302 m_forum_rated = false; 298 303 … … 329 334 return; 330 335 } 336 337 // получение информации о себе 338 QSettings settings; 339 340 m_me.Name = settings.value("rsdn/login", "").toString(); 341 342 storage->whoAmI(m_me, NULL); 331 343 332 344 // если группа форумов обыкновенная … … 464 476 } 465 477 466 if (storage->getTopicInfo (list, 0) == false)478 if (storage->getTopicInfoList(list, m_me.ID, NULL) == false) 467 479 { 468 480 storage->showError(m_parent); … … 483 495 item_info->UnreadChildCount = 0; 484 496 item_info->IsBodyLoaded = false; 485 item_info->HasUnreadChild = info.HasUnreadChild;486 497 item_info->Special = 0; 487 498 … … 498 509 { 499 510 if (info.HasUnreadChild != 0) 500 item->setIcon(0, m_child_unread); 511 { 512 if (info.HasUnreadChild == 2) 513 item->setIcon(0, m_child_unread_my); 514 else 515 item->setIcon(0, m_child_unread); 516 } 501 517 else 502 518 item->setIcon(0, m_message_read); 503 519 } 504 520 else 505 item->setIcon(0, m_message_unread); 521 { 522 if (info.HasUnreadChild == 2) 523 item->setIcon(0, m_message_unread_my); 524 else 525 item->setIcon(0, m_message_unread); 526 } 506 527 507 528 if (info.HasChild == true) … … 531 552 532 553 // получение сообщений 533 A MessageInfoExList list;534 535 if (storage->getTopicMessageList(item->pag()->Info.ID, list, NULL) == false)554 ATopicInfoList list; 555 556 if (storage->getTopicMessageList(item->pag()->Info.ID, list, m_me.ID, NULL) == false) 536 557 { 537 558 storage->showError(m_parent); … … 567 588 //---------------------------------------------------------------------------------------------- 568 589 569 void AMessageTree::buildTree (QTreeWidgetItem* parent, A MessageInfoExList* list)590 void AMessageTree::buildTree (QTreeWidgetItem* parent, ATopicInfoList* list) 570 591 { 571 592 … … 580 601 while (index < size) 581 602 { 582 A MessageInfoExinfo = list->at(index);603 ATopicInfo info = list->at(index); 583 604 584 605 if (info.IDParent == id_parent) … … 609 630 610 631 // ATopicInfo 611 item_info->Info.HasChild = false; 632 item_info->Info.HasChild = info.HasChild; 633 item_info->Info.HasUnreadChild = 0; 612 634 613 635 // AMessageInfoGUI … … 641 663 MessageTreeWidgetItem* temp_item = parent_item; 642 664 643 bool set_icon = true;644 645 665 while (temp_item != NULL) 646 666 { 647 if (set_icon == true && temp_item->pag()->Info.IsRead == true) 648 temp_item->setIcon(0, m_child_unread); 649 else 650 set_icon = false; 651 652 temp_item->pag()->UnreadChildCount++; 667 AMessageInfoGUI* temp_info = temp_item->pag(); 668 669 if (info.HasUnreadChild == 2) 670 temp_info->Info.HasUnreadChild = 2; 671 672 if (temp_info->Info.IsRead == true) 673 { 674 if (temp_info->Info.HasUnreadChild == 2) 675 temp_item->setIcon(0, m_child_unread_my); 676 else 677 temp_item->setIcon(0, m_child_unread); 678 } 679 else if (temp_info->Info.HasUnreadChild == 2) 680 temp_item->setIcon(0, m_message_unread_my); 681 682 temp_info->UnreadChildCount++; 653 683 654 684 temp_item = (MessageTreeWidgetItem*)temp_item->parent(); … … 772 802 { 773 803 if (info->UnreadChildCount != 0) 774 item->setIcon(0, m_child_unread); 804 { 805 if (info->Info.HasUnreadChild == 2) 806 item->setIcon(0, m_child_unread_my); 807 else 808 item->setIcon(0, m_child_unread); 809 } 775 810 else 776 811 { 777 if (item->parent() == NULL && info->IsChildLoaded == false && info->HasUnreadChild != false) 778 item->setIcon(0, m_child_unread); 812 if (item->parent() == NULL && info->IsChildLoaded == false && info->Info.HasUnreadChild != 0) 813 { 814 if (info->Info.HasUnreadChild == 2) 815 item->setIcon(0, m_child_unread_my); 816 else 817 item->setIcon(0, m_child_unread); 818 } 779 819 else 780 820 { 781 821 item->setIcon(0, m_message_read); 782 info-> HasUnreadChild = false;822 info->Info.HasUnreadChild = 0; 783 823 } 784 824 } … … 794 834 if (parent_info->Info.IsRead == true && parent_info->UnreadChildCount == 0) 795 835 { 796 parent_info-> HasUnreadChild = false;836 parent_info->Info.HasUnreadChild = 0; 797 837 parent_item->setIcon(0, m_message_read); 798 838 } … … 806 846 else 807 847 { 808 item->setIcon(0, m_message_unread); 848 if (info->Info.HasUnreadChild == 2) 849 item->setIcon(0, m_message_unread_my); 850 else 851 item->setIcon(0, m_message_unread); 809 852 810 853 MessageTreeWidgetItem* parent_item = static_cast<MessageTreeWidgetItem*>(item->parent()); … … 815 858 816 859 parent_info->UnreadChildCount++; 817 parent_info-> HasUnreadChild = true;860 parent_info->Info.HasUnreadChild = 1; // TODO: обновить в соответствии с ответами мне 818 861 819 862 if (parent_info->Info.IsRead == true) 820 parent_item->setIcon(0, m_child_unread); 863 { 864 if (parent_info->Info.HasUnreadChild == 2) 865 parent_item->setIcon(0, m_child_unread_my); 866 else 867 parent_item->setIcon(0, m_child_unread); 868 } 821 869 822 870 parent_item = static_cast<MessageTreeWidgetItem*>(parent_item->parent()); 823 871 } 824 872 825 // у меньшение количества непрочитанных в дереве форума873 // увеличение количества непрочитанных в дереве форума 826 874 m_forum_tree->changeUnreadCount(1); 827 875 } … … 862 910 item_parent->setIcon(0, m_message_read); 863 911 864 item_parent->pag()->Info.IsRead = is_read;865 item_parent->pag()->UnreadChildCount = 0;866 item_parent->pag()-> HasUnreadChild = is_read;912 item_parent->pag()->Info.IsRead = is_read; 913 item_parent->pag()->UnreadChildCount = 0; 914 item_parent->pag()->Info.HasUnreadChild = (is_read == true ? 1 : 0); // TODO: обновить в соответствии с ответами мне 867 915 868 916 for (int i = 0; i < item_parent->childCount(); i++) … … 879 927 while (temp_parent != NULL) 880 928 { 881 temp_parent->pag()-> HasUnreadChild = is_read;929 temp_parent->pag()->Info.HasUnreadChild = (is_read == true ? 1 : 0); // TODO: обновить в соответствии с ответами мне 882 930 temp_parent->pag()->UnreadChildCount++; 883 931 temp_parent = static_cast<MessageTreeWidgetItem*>(temp_parent->parent()); … … 929 977 markThreadAsRead(parent, true, count); 930 978 931 item_parent->pag()-> HasUnreadChild = false;979 item_parent->pag()->Info.HasUnreadChild = 0; // TODO: обновить в соответствии с ответами мне 932 980 933 981 m_forum_tree->changeUnreadCount(-count); … … 937 985 item_parent->setIcon(0, m_message_read); 938 986 939 item_parent->pag()-> HasUnreadChild = false;987 item_parent->pag()->Info.HasUnreadChild = 0; // TODO: обновить в соответствии с ответами мне 940 988 941 989 // поскольку дочерние элементы еще не загружены, … … 985 1033 markThreadAsRead(parent, false, count); 986 1034 987 item_parent->pag()-> HasUnreadChild = true;1035 item_parent->pag()->Info.HasUnreadChild = 1; // TODO: Обновить в соответствии с ответами мне 988 1036 989 1037 m_forum_tree->changeUnreadCount(count); … … 993 1041 item_parent->setIcon(0, m_message_unread); 994 1042 995 item_parent->pag()-> HasUnreadChild = true;1043 item_parent->pag()->Info.HasUnreadChild = 1; // TODO: Обновить в соответствии с ответами мне 996 1044 997 1045 // поскольку дочерние элементы еще не загружены, … … 1068 1116 info->IsInfoLoaded = true; 1069 1117 info->IsChildLoaded = true; 1070 info->HasUnreadChild = 0;1071 1118 info->UnreadChildCount = 0; 1072 1119 info->IsBodyLoaded = true; … … 1210 1257 break; 1211 1258 1212 if (item->pag()-> HasUnreadChild == true)1259 if (item->pag()->Info.HasUnreadChild != 0) 1213 1260 item->setExpanded(true); 1214 1261 … … 1249 1296 MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(ATreeWidgetItem::rootItem(currentItem())); 1250 1297 1251 if (item->pag()-> HasUnreadChild == true|| item->pag()->Info.IsRead == false)1298 if (item->pag()->Info.HasUnreadChild != 0 || item->pag()->Info.IsRead == false) 1252 1299 return; 1253 1300 } … … 1278 1325 item = static_cast<MessageTreeWidgetItem*>(ATreeWidgetItem::firstSibling(ATreeWidgetItem::rootItem(item))); 1279 1326 1280 if (item->pag()-> HasUnreadChild == true|| item->pag()->Info.IsRead == false)1327 if (item->pag()->Info.HasUnreadChild != 0 || item->pag()->Info.IsRead == false) 1281 1328 break; 1282 1329 } … … 1337 1384 info->IsInfoLoaded = true; 1338 1385 info->IsChildLoaded = true; 1339 info->HasUnreadChild = 0;1340 1386 info->UnreadChildCount = 0; 1341 1387 info->IsBodyLoaded = true; … … 1431 1477 info->IsInfoLoaded = true; 1432 1478 info->IsChildLoaded = true; 1433 info->HasUnreadChild = 0;1434 1479 info->UnreadChildCount = 0; 1435 1480 info->IsBodyLoaded = true; -
trunk/message_tree.h
r171 r175 80 80 81 81 // иконки для отображения статусов сообщений 82 QIcon m_message_read; /*!< \brief Сообщение прочитано */ 83 QIcon m_child_unread; /*!< \brief Есть непрочитанные дочерние сообщения */ 84 QIcon m_message_unread; /*!< \brief Сообщение не прочитано */ 82 QIcon m_message_read; /*!< \brief Сообщение прочитано */ 83 QIcon m_child_unread; /*!< \brief Есть непрочитанные дочерние сообщения */ 84 QIcon m_message_unread; /*!< \brief Сообщение не прочитано */ 85 QIcon m_child_unread_my; /*!< \brief В ветке есть сообщение для меня */ 86 QIcon m_message_unread_my; /*!< \brief В ветке есть сообщение для меня */ 85 87 86 88 // иконки для отображения оценок … … 143 145 144 146 /*! 147 * \brief ID текущего пользователя RSDN 148 */ 149 AUserInfo m_me; 150 151 /*! 145 152 * \brief Функция проверки установки выделения, в случае отсутствия выделения, выделяет элемент, согласно параметру select_first 146 153 * \param select_first Флаг выделения, если имеет значение true, то выделяется первый элемент, иначе, последний (из корневых) … … 165 172 * \param list список _всех_ дочерних веток (все уровни вложенности) 166 173 */ 167 void buildTree (QTreeWidgetItem* parent, A MessageInfoExList* list);174 void buildTree (QTreeWidgetItem* parent, ATopicInfoList* list); 168 175 169 176 /*! -
trunk/resource.qrc
r161 r175 7 7 <file>icons/messageread.png</file> 8 8 <file>icons/messageunread.png</file> 9 <file>icons/myunread.png</file> 9 10 10 11 <file>icons/exit16.png</file> -
trunk/storage/istorage.h
r171 r175 139 139 * тело сообщения будет запрошено при помощи IAStorage::GetMessageBody, по мере необходимости. 140 140 * \param list Список топиков. 141 * \param progress Прогресс выполнения операции. 142 */ 143 virtual bool getTopicInfo (ATopicInfoList& list, IProgress* progress = NULL) = 0; 141 * \param id_me ID текущего пользователя 142 * \param progress Прогресс выполнения операции. 143 */ 144 virtual bool getTopicInfoList (ATopicInfoList& list, int id_me, IProgress* progress = NULL) = 0; 144 145 145 146 /*! … … 148 149 * \param id_topic ID топика (темы, родительской ветки). 149 150 * \param list Список сообщений. 150 * \param progress Прогресс выполнения операции. 151 */ 152 virtual bool getTopicMessageList (int id_topic, AMessageInfoExList& list, IProgress* progress = NULL) = 0; 151 * \param id_me ID текущего пользователя 152 * \param progress Прогресс выполнения операции. 153 */ 154 virtual bool getTopicMessageList (int id_topic, ATopicInfoList& list, int id_me, IProgress* progress = NULL) = 0; 153 155 154 156 /*! -
trunk/storage/mysql_storage.cpp
r174 r175 1929 1929 //---------------------------------------------------------------------------------------------- 1930 1930 1931 bool AMySQLStorage::getTopicInfo (ATopicInfoList& list, IProgress* progress)1931 bool AMySQLStorage::getTopicInfoList (ATopicInfoList& list, int id_me, IProgress* progress) 1932 1932 { 1933 1933 if (progress != NULL) … … 2049 2049 sql = ""; 2050 2050 sql += "SELECT\n"; 2051 sql += " `id_topic`\n"; 2051 sql += " `id_topic`,\n"; 2052 sql += " SUM(IF(`id_parent_user` = " + QString::number(id_me) + ", 2, 0))\n"; 2052 2053 sql += "FROM\n"; 2053 2054 sql += " `unread`\n"; … … 2068 2069 { 2069 2070 int id = query_select_unread_child->value(0).toInt(); 2071 int id_parent_user = query_select_unread_child->value(1).toInt(); 2070 2072 2071 2073 for (int i = 0; i < list.count(); i++) 2072 2074 if (id == list[i].ID) 2073 2075 { 2074 list[i].HasUnreadChild = 1; 2076 if (id_parent_user > 1) 2077 list[i].HasUnreadChild = 2; 2078 else 2079 list[i].HasUnreadChild = 1; 2080 2075 2081 break; 2076 2082 } … … 2081 2087 //---------------------------------------------------------------------------------------------- 2082 2088 2083 bool AMySQLStorage::getTopicMessageList (int id_topic, A MessageInfoExList& list, IProgress* progress)2089 bool AMySQLStorage::getTopicMessageList (int id_topic, ATopicInfoList& list, int id_me, IProgress* progress) 2084 2090 { 2085 2091 if (progress != NULL) … … 2107 2113 sql += " `user_title`,\n"; 2108 2114 sql += " `user_title_color`,\n"; 2109 sql += " `last_moderated`\n"; 2115 sql += " `last_moderated`,\n"; 2116 sql += " `has_child`\n"; 2110 2117 sql += "FROM\n"; 2111 2118 sql += " `message`\n"; … … 2125 2132 while (query_select->next()) 2126 2133 { 2127 A MessageInfoExinfo;2134 ATopicInfo info; 2128 2135 2129 2136 info.ID = query_select->value(0).toInt(); … … 2142 2149 info.UserTitleColor = query_select->value(13).toInt(); 2143 2150 info.LastModerated = query_select->value(14).toDateTime(); 2151 info.HasChild = query_select->value(15).toInt(); 2144 2152 2145 2153 info.IsRead = true; 2154 info.HasUnreadChild = 0; 2146 2155 2147 2156 list.append(info); … … 2154 2163 sql = ""; 2155 2164 sql += "SELECT\n"; 2156 sql += " `id_message`\n"; 2165 sql += " `id_message`,\n"; 2166 sql += " `id_parent_user`\n"; 2157 2167 sql += "FROM\n"; 2158 2168 sql += " `unread`\n"; … … 2173 2183 { 2174 2184 int id = query_select_unread->value(0).toInt(); 2185 int id_parent_user = query_select_unread->value(1).toInt(); 2175 2186 2176 2187 for (int i = 0; i < list.count(); i++) 2177 2188 if (list[i].ID == id) 2178 2189 { 2190 if (id_parent_user == id_me) 2191 list[i].HasUnreadChild = 2; 2192 2179 2193 list[i].IsRead = false; 2180 2194 //list.move(i, 0); -
trunk/storage/mysql_storage.h
r171 r175 57 57 bool getUnreadCount (AUnreadForumCountInfoList& list, IProgress* progress = NULL); 58 58 bool getForumTopicList (int id_forum, int count, QList<int>& list, IProgress* progress = NULL); 59 bool getTopicInfo (ATopicInfoList& list, IProgress* progress = NULL);60 bool getTopicMessageList (int id_topic, A MessageInfoExList& list, IProgress* progress = NULL);59 bool getTopicInfoList (ATopicInfoList& list, int id_me, IProgress* progress = NULL); 60 bool getTopicMessageList (int id_topic, ATopicInfoList& list, int id_me, IProgress* progress = NULL); 61 61 bool getMessageBody (int id_message, QString& body, IProgress* progress = NULL); 62 62 bool setIDsAsRead (const QList<int>& list, AIDSet type, bool read, QDateTime date, IProgress* progress = NULL); -
trunk/sysheaders.h
r173 r175 27 27 #include <QMenuBar> 28 28 #include <QToolBar> 29 #include <QPainter> 29 30 #include <QProcess> 30 31 #include <QLineEdit> -
trunk/version.h
r174 r175 20 20 * \brief Дата билда (заменяется автоматически при каждом билде в version.h, что и приводит к смене номера ревизии) 21 21 */ 22 #define AVALON_DATE " Вск Мар 22 05:10:29MSK 2009"22 #define AVALON_DATE "Пнд Мар 23 02:58:53 MSK 2009" 23 23 24 24 #endif
Note: See TracChangeset
for help on using the changeset viewer.
