From 632b49ab9091b114bae21647e82e17f6e1c9fd08 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 16 Jun 2015 02:37:07 +0000 Subject: [PATCH] fixed: meta and admin meta information were not saved in memory (in system.dirs) when 'meta' winix function was used added: to DbItemsQuery sort_index_asc and sort_index_date different sort type can be made by 'index' and by 'date' git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1013 e52654a7-88a9-db11-a3e9-0013d4bc506e --- db/db.cpp | 18 +++++++++++++----- db/db.h | 1 + db/dbitemquery.cpp | 5 +++-- db/dbitemquery.h | 5 +++-- functions/meta.cpp | 12 +++++++++++- plugins/export/exportthread.cpp | 4 ---- plugins/menu/templates.cpp | 3 ++- plugins/thread/funthread.cpp | 2 +- 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/db/db.cpp b/db/db.cpp index b2a190b..1dfa5f2 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -869,6 +869,15 @@ void Db::GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query) } +void Db::GetItemsQueryOrder(bool sort_asc) +{ + if( sort_asc ) + query << R(" asc"); + else + query << R(" desc"); +} + + void Db::GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query) { if( iq.sel_sort_index || iq.sel_date ) @@ -876,7 +885,10 @@ void Db::GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query) query << R(" order by"); if( iq.sel_sort_index ) + { query << R(" sort_index"); + GetItemsQueryOrder(iq.sort_index_asc); + } if( iq.sel_date ) { @@ -884,12 +896,8 @@ void Db::GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query) query << R(","); query << R(" item.date_creation"); + GetItemsQueryOrder(iq.sort_date_asc); } - - if( iq.sort_asc ) - query << R(" asc"); - else - query << R(" desc"); } } diff --git a/db/db.h b/db/db.h index 7537a30..681cc8c 100644 --- a/db/db.h +++ b/db/db.h @@ -159,6 +159,7 @@ protected: void GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel); void GetItemsQueryJoin(const DbItemQuery & iq, DbTextStream & query); void GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query); + void GetItemsQueryOrder(bool sort_asc); void GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query); void GetItemsQueryLimit(const DbItemQuery & iq, DbTextStream & query); PGresult * GetItemsQuery(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel = false); diff --git a/db/dbitemquery.cpp b/db/dbitemquery.cpp index b2e675e..faa8346 100644 --- a/db/dbitemquery.cpp +++ b/db/dbitemquery.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2010-2014, Tomasz Sowa + * Copyright (c) 2010-2015, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,8 @@ DbItemQuery::DbItemQuery() void DbItemQuery::Clear() { - sort_asc = true; + sort_index_asc = true; + sort_date_asc = true; SetAll(true, false); diff --git a/db/dbitemquery.h b/db/dbitemquery.h index 7bb99b8..9f1eed6 100644 --- a/db/dbitemquery.h +++ b/db/dbitemquery.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2010-2014, Tomasz Sowa + * Copyright (c) 2010-2015, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,8 @@ struct DbItemQuery bool type_equal; int file_type; bool file_type_equal; // if true means file_type should be equal - bool sort_asc; + bool sort_index_asc; + bool sort_date_asc; const std::vector * id_tab; // != 0 if WhereIdIn was used diff --git a/functions/meta.cpp b/functions/meta.cpp index 4db3bbd..8cb94dd 100644 --- a/functions/meta.cpp +++ b/functions/meta.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2011-2014, Tomasz Sowa + * Copyright (c) 2011-2015, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -133,7 +133,12 @@ void Meta::ChangeAdminMeta() const std::wstring & meta_str = cur->request->PostVar(L"itemmeta"); if( EditAdminMeta(cur->request->last_item->id, meta_str, true) ) + { + if( cur->request->last_item->type == Item::dir ) + cur->request->last_item->ameta = space; + system->RedirectToLastItem(); + } } } @@ -145,7 +150,12 @@ void Meta::ChangeMeta() const std::wstring & meta_str = cur->request->PostVar(L"itemmeta"); if( EditMeta(cur->request->last_item->id, meta_str, true) ) + { + if( cur->request->last_item->type == Item::dir ) + cur->request->last_item->meta = space; + system->RedirectToLastItem(); + } } } diff --git a/plugins/export/exportthread.cpp b/plugins/export/exportthread.cpp index 616ae75..404d364 100644 --- a/plugins/export/exportthread.cpp +++ b/plugins/export/exportthread.cpp @@ -72,12 +72,8 @@ void ExportThread::SetBaseUrl(const std::wstring & url) void ExportThread::AddMessage(const Message & message) { - log << log1 << "export thread: a" << logsave << logend; - message_tab.insert(message_tab.end(), message); WakeUpThread(); - - log << log1 << "export thread: b" << logsave << logend; } diff --git a/plugins/menu/templates.cpp b/plugins/menu/templates.cpp index 85e7830..a6c6e6d 100644 --- a/plugins/menu/templates.cpp +++ b/plugins/menu/templates.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2011-2014, Tomasz Sowa + * Copyright (c) 2011-2015, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -106,6 +106,7 @@ void read_from_db(long dir_id, int param, bool with_meta) iq.sel_subject = true; iq.sel_url = true; iq.sel_sort_index = true; + iq.sort_date_asc = false; // !! FIXED ME we need an option for this iq.sel_type = true; iq.sel_file = true; iq.sel_meta = with_meta; diff --git a/plugins/thread/funthread.cpp b/plugins/thread/funthread.cpp index 3805b56..1602631 100644 --- a/plugins/thread/funthread.cpp +++ b/plugins/thread/funthread.cpp @@ -86,7 +86,7 @@ void FunThread::PrepareThread(long file_id) DbItemQuery iq; if( system->mounts.pmount->IsArg(thread_info->mount_par_thread, L"sort_desc") ) - iq.sort_asc = false; + iq.sort_date_asc = false; // sort_index_asc we are ignoring iq.WhereIdIn(id_tab); iq.WhereType(Item::file);