Changeset 249


Ignore:
Timestamp:
06/29/09 04:04:33 (3 years ago)
Author:
antonbatenev.ya.ru
Message:

Добавление попытки перехода внутри avalon если встречается ссылка на сообщение и она присутствует в хранлище

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/message_tree.cpp

    r233 r249  
    13501350                external_url.replace("avalon:", ""); 
    13511351 
    1352                 QDesktopServices::openUrl(external_url); 
     1352                // проверка на то, что URL является ссылкой на сообщение RSDN 
     1353                QRegExp rsdn_url("$(http://){0,1}((www|gzip)\\.){0,1}rsdn.ru/forum/.+/(\\d+)\\.(1|flat|aspx)", Qt::CaseInsensitive); 
     1354 
     1355                if (rsdn_url.indexIn(external_url) == -1) 
     1356                        QDesktopServices::openUrl(external_url); 
     1357                else 
     1358                { 
     1359                        // URL является ссылкой на сообщение RSDN, получение id сообщения 
     1360                        QList<int> path; 
     1361 
     1362                        bool is_int     = false; 
     1363                        int  id_forum   = 0; 
     1364                        int  id_message = rsdn_url.cap(4).toInt(&is_int); 
     1365 
     1366                        // проверка того, что текущее выделение не есть это же сообщение 
     1367                        MessageTreeWidgetItem* item = static_cast<MessageTreeWidgetItem*>(currentItem()); 
     1368 
     1369                        if (item != NULL && item->pag()->ID == id_message) 
     1370                        { 
     1371                                QDesktopServices::openUrl(external_url); 
     1372                                return; 
     1373                        } 
     1374 
     1375                        // попытка получения пути сообщения 
     1376                        std::auto_ptr<IAStorage> storage(AStorageFactory::getStorage()); 
     1377 
     1378                        // "тихая" отработка ошибок, т.к. ошибки не критичны 
     1379                        if (storage.get() == NULL) 
     1380                        { 
     1381                                QDesktopServices::openUrl(external_url); 
     1382                                return; 
     1383                        } 
     1384 
     1385                        if (storage->getMessagePath(id_message, id_forum, path, NULL) == false) 
     1386                        { 
     1387                                QDesktopServices::openUrl(external_url); 
     1388                                return; 
     1389                        } 
     1390 
     1391                        if (id_forum == 0 || path.count() == 0) 
     1392                        { 
     1393                                QDesktopServices::openUrl(external_url); 
     1394                                return; 
     1395                        } 
     1396 
     1397                        if (m_current_forum.ID != id_forum && (m_forum_tree == NULL || m_forum_tree->selectForum(id_forum) == false)) 
     1398                        { 
     1399                                QDesktopServices::openUrl(external_url); 
     1400                                return; 
     1401                        } 
     1402 
     1403                        // переход на сообщение 
     1404                        selectByPath(&path); 
     1405                } 
    13531406 
    13541407                return; 
  • trunk/message_view.cpp

    r152 r249  
    8585        QString special = url.toString(); 
    8686 
    87         if (special.indexOf("avalon:") != 0) 
     87        if (m_message_tree != NULL) 
     88                m_message_tree->processUrl(special); 
     89        else 
    8890                QDesktopServices::openUrl(url); 
    89         else if (m_message_tree != NULL) 
    90                 m_message_tree->processUrl(special); 
    9191} 
    9292//---------------------------------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.