File: GUI_Main_Easy_Box_Core.cpp

package info (click to toggle)
mediainfo 25.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,656 kB
  • sloc: cpp: 18,871; objc: 3,102; xml: 1,426; sh: 1,328; python: 263; makefile: 212
file content (228 lines) | stat: -rw-r--r-- 8,171 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license that can
 *  be found in the License.html file in the root of the source tree.
 */

//---------------------------------------------------------------------------
#include "GUI/Common/GUI_Main_Easy_Box_Core.h"
#include "GUI/Common/GUI_Main_Easy_Core.h"
#include "ZenLib/Conf.h"
using namespace ZenLib;
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
const size_t Title_Pos=156; //TODO: Position of Title in General.csv, should shange this...
//---------------------------------------------------------------------------

//***************************************************************************
// Constructor/Destructor
//***************************************************************************

//---------------------------------------------------------------------------
GUI_Main_Easy_Box_Core::GUI_Main_Easy_Box_Core(Core* Core_, GUI_Main_Easy_Core* Parent_Core_, stream_t StreamKind, size_t StreamPos)
{
    //Internal
    C=Core_;
    Parent_Core=Parent_Core_;

    //Configuration
    GUI_Main_Easy_Box_Core::StreamKind=StreamKind;
    GUI_Main_Easy_Box_Core::StreamPos=StreamPos;
}

//***************************************************************************
// Actions - Per StreamKind
//***************************************************************************

//---------------------------------------------------------------------------
size_t GUI_Main_Easy_Box_Core::Boxes_Count_Get()
{
    return Parent_Core->Boxes_Count_Get(StreamKind);
}

//---------------------------------------------------------------------------
size_t GUI_Main_Easy_Box_Core::Boxes_Show_Get()
{
    size_t StreamCount=Parent_Core->StreamsCount_Get(StreamKind);
    if (Parent_Core->StreamsCount_Get(Stream_General)==0)
        StreamCount=Boxes_Count_Get();
    if (StreamCount>Boxes_Count_Get())
        StreamCount=Boxes_Count_Get();
    return StreamCount;
}

//---------------------------------------------------------------------------
size_t GUI_Main_Easy_Box_Core::Lines_Count_Get()
{
    switch (StreamKind)
    {
        case 0 : return 5;
        case 1 : return 2;
        case 2 : return 2;
        case 3 : return 2;
        default: return 0;
    }
}

//***************************************************************************
// Actions - Per Stream
//***************************************************************************

//---------------------------------------------------------------------------
bool GUI_Main_Easy_Box_Core::MustHide()
{
    size_t StreamCount=C->MI->Count_Get(Parent_Core->FilesPos_Get(), StreamKind);
    if (Parent_Core->StreamsCount_Get(Stream_General)==0)
        StreamCount=Boxes_Count_Get();
    if (StreamCount<=StreamPos)
        return true;
    else
        return false;
}

//---------------------------------------------------------------------------
bool GUI_Main_Easy_Box_Core::IsLastBox()
{
    if (StreamPos+1==Boxes_Show_Get())
        return true;
    else
        return false;
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::Box_Get()
{
    String Temp;
    switch (StreamKind)
    {
        case Stream_General : Temp=__T("General"); break;
        case Stream_Video   : Temp=__T("Video");   break;
        case Stream_Audio   : Temp=__T("Audio");   break;
        case Stream_Text    : Temp=__T("Text");    break;
        default             : Temp=__T("");
    }

    return Temp;
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::Text_Get()
{
    //First line
    if (Lines_Count_Get()==0)
        return __T("");
    String Temp=Parent_Core->Summary_Get(StreamKind, StreamPos);

    //Depend of StreamKind
    if (Parent_Core->StreamsCount_Get(Stream_General)==0)
    {
        //Empty box
        Temp+=EOL;
        Temp+=EOL;
    }
    else if (StreamKind==Stream_General)
    {
        //Stream_General
        size_t Lines=1;
        for (int KindOfStream=1; KindOfStream<Stream_Max; KindOfStream++)
        {
            if (C->MI->Count_Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream)>0)
            {
                String Z1=String(C->MI->Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream, 0, __T("StreamKind"), Info_Measure))+__T("StreamCount");
                String Z2=String(__T(" "))+C->MI->Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream, 0, __T("StreamKind"), Info_Text);
                if (C->MI->Count_Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream)==1)
                    Z2+=__T(" stream");//__T(" stream1");
                else
                    Z2+=__T(" streams");//__T(" stream2");
                String Z3=String(C->MI->Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream, 0, __T("StreamKind"), Info_Text)+__T("_Format_WithHint_List"));
                Temp+=EOL;
                Temp+=(C->MI->Get(Parent_Core->FilesPos_Get(), (stream_t)KindOfStream, 0, Z1)+/*Prefs->Translate(*/Z2/*)*/+/*Prefs->Translate(*/__T(": ")/*)*/+C->MI->Get(Parent_Core->FilesPos_Get(), Stream_General, 0, Z3)).c_str();
                Lines++;
            }

            if (Lines>=Lines_Count_Get())
                KindOfStream=Stream_Max;
        }
    }
    else if (Lines_Count_Get()>1)
    {
        //Other than Stream_General
        String Title=C->MI->Get(Parent_Core->FilesPos_Get(), StreamKind, StreamPos, __T("Title"));
        if (!Title.empty())
        {
            Temp+=EOL;
            Temp+=Title;
        }
    }

    return Temp.c_str();
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::ToolTip_Get()
{
    return Parent_Core->Inform_Get(StreamKind, StreamPos);
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::Tags_Get()
{
    //First line
    if (StreamKind!=Stream_General || Lines_Count_Get()==0)
        return __T("");

    size_t MI_Pos=Title_Pos; //Should begin with "Title"
    size_t MI_Max=C->MI->Count_Get(Parent_Core->FilesPos_Get(), Stream_General, 0);
    String Temp;
    size_t Lines=0;
    while(MI_Pos<MI_Max)
    {
        String Z1=C->MI->Get(Parent_Core->FilesPos_Get(), Stream_General, 0, MI_Pos);
        String Options=C->MI->Get(Parent_Core->FilesPos_Get(), Stream_General, 0, MI_Pos, Info_Options);
        if (Options.size()>InfoOption_ShowInInform && Options[InfoOption_ShowInInform]==__T('Y') && Z1.size()>0)
        {
            String Z2=C->MI->Get(Parent_Core->FilesPos_Get(), Stream_General, 0, MI_Pos, Info_Name_Text);
            if (Z2.size()==0)
                Z2=C->MI->Get(Parent_Core->FilesPos_Get(), Stream_General, 0, MI_Pos, Info_Name);
            Z2+=/*Prefs->Translate(*/__T(": ")/*)*/;
            Z2+=Z1;
            if (Lines>0)
                Temp+=EOL;
            Temp+=Z2;

            Lines++;
            if (Lines>=Lines_Count_Get())
                MI_Pos=MI_Max;
        }
        MI_Pos++;
    }

    return Temp;
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::Button_Get()
{
    if (StreamKind==Stream_General)
        return __T("Go to the website of a player for this file");
    else
        return __T("Go to the website of this codec");
}

//---------------------------------------------------------------------------
bool GUI_Main_Easy_Box_Core::Button_Show()
{
    if (Parent_Core->CodecID_Url_Get(StreamKind, StreamPos).empty())
        return false;
    else
        return true;
}

//---------------------------------------------------------------------------
String GUI_Main_Easy_Box_Core::Button_Click()
{
    return Parent_Core->CodecID_Url_Get(StreamKind, StreamPos);
}