added: new winix function: "sort"
sorting items in a directory (Item::sort_index is used) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@754 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
66
functions/sort.h
Executable file
66
functions/sort.h
Executable file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_functions_sort
|
||||
#define headerfile_winix_functions_sort
|
||||
|
||||
#include "functionbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
|
||||
class Sort : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
Sort();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
DbItemQuery iq;
|
||||
std::vector<size_t> item_tab; // indexes to cur->request->item_tab
|
||||
|
||||
struct SortPair
|
||||
{
|
||||
long id;
|
||||
int sort_index;
|
||||
};
|
||||
|
||||
std::vector<SortPair> item_tab2; // from post table
|
||||
|
||||
// for sorting item_tab
|
||||
struct SortHelper
|
||||
{
|
||||
Sort * psort;
|
||||
|
||||
SortHelper(Sort * s) : psort(s) {}
|
||||
bool operator()(size_t t1, size_t t2);
|
||||
};
|
||||
|
||||
// for sorting item_tab2
|
||||
static bool SortFun2(const SortPair & s1, const SortPair & s2);
|
||||
|
||||
void GetDirContent();
|
||||
void CreateItemTab();
|
||||
void CreateItemTab2();
|
||||
void UpdateSortIndex(Item & item, int sort_index);
|
||||
void UpdateSortIndexes();
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user