moved some thread files to plugins/thread
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@705 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
89
plugins/thread/funthread.cpp
Executable file
89
plugins/thread/funthread.cpp
Executable file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "core/misc.h"
|
||||
#include "funthread.h"
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
FunThread::FunThread()
|
||||
{
|
||||
fun.url = L"thread";
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunThread::HasAccess()
|
||||
{
|
||||
return !request->is_item;
|
||||
}
|
||||
|
||||
|
||||
void FunThread::Clear()
|
||||
{
|
||||
thread.Clear();
|
||||
thread_tab.clear();
|
||||
}
|
||||
|
||||
|
||||
void FunThread::CreateSortIndexByDate()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < thread_tab.size() ; ++i)
|
||||
{
|
||||
Item * pdir = system->dirs.GetDir(thread_tab[i].dir_id);
|
||||
|
||||
if( pdir )
|
||||
thread_tab[i].sort = (unsigned long)Time(pdir->date_creation);
|
||||
else
|
||||
thread_tab[i].sort = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunThread::FunThreadSort(const Thread & t1, const Thread & t2)
|
||||
{
|
||||
return t1.sort > t2.sort;
|
||||
}
|
||||
|
||||
|
||||
void FunThread::MakeGet()
|
||||
{
|
||||
is_thread = (db->GetThreadByDirId(request->dir_tab.back()->id, thread) == WINIX_ERR_OK);
|
||||
|
||||
DbItemQuery iq;
|
||||
|
||||
if( system->mounts.pmount->IsArg(system->mounts.MountParThread(), L"sort_desc") )
|
||||
iq.sort_asc = false;
|
||||
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(request->item_tab, iq);
|
||||
db->GetThreads(request->dir_tab.back()->id, thread_tab);
|
||||
|
||||
system->CheckAccessToItems(request->item_tab);
|
||||
|
||||
CreateSortIndexByDate();
|
||||
std::sort(thread_tab.begin(), thread_tab.end(), FunThreadSort);
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user