Skip to content

Commit 46b736c

Browse files
author
yosholo
committed
row is updated when a new scan is readed, and add two new list to navigate through the chapters of a scan
1 parent d5167a3 commit 46b736c

File tree

7 files changed

+156
-180
lines changed

7 files changed

+156
-180
lines changed

Easylast.cpp

+11-16
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,21 @@ string Easylast::find_summary(const string name,const int & chap)
7373
return ret;
7474

7575
}
76-
vector<string> Easylast::list_pages_scan(const string & path)
77-
{
78-
vector<dirent *> list_file;
79-
vector<string> list_name_img;
80-
81-
list_file = list_dir(path);
82-
83-
for(vector<dirent *>::iterator i=list_file.begin();i!=list_file.end();++i)
84-
list_name_img.push_back((*i)->d_name);
85-
86-
return list_name_img;
87-
}
88-
8976

90-
vector<dirent *> Easylast::list_dir( const string & path)
77+
vector<string> Easylast::list_dir( const string & path)
9178
{
92-
vector<dirent *> list_dir_scan;
79+
vector<string> list_dir_scan;
9380
DIR* d = opendir(path.c_str());
9481
struct dirent *ent = NULL;
9582

9683
while ((ent = readdir(d)) != NULL)
9784
{
9885
if (strcmp(ent->d_name, ".") != 0 &&
9986
strcmp(ent->d_name, "..") != 0)
100-
list_dir_scan.push_back(ent);
87+
{
88+
// cout << ent->d_name << endl;
89+
list_dir_scan.push_back(ent->d_name);
90+
}
10191
}
10292

10393
return list_dir_scan;
@@ -130,3 +120,8 @@ int Easylast::stoi(const string & i)
130120
{
131121
return atoi(i.c_str());
132122
}
123+
124+
int Easylast::qstoi(const QString & i)
125+
{
126+
return atoi(i.toStdString().c_str());
127+
}

Easylast.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ static vector<string> split(const string & msg,const string str_sep);
2424
static map<string,string> parse_info(const string & type);
2525
static string find_summary(const string name,const int & chap);
2626

27-
static vector<dirent *> list_dir( const string & path);
28-
static vector<string> list_pages_scan(const string & path);
27+
static vector<string> list_dir( const string & path);
2928
static bool is_dir(string path);
3029

3130
static string itos(const int & i);
3231
static int stoi(const string & i);
32+
static int qstoi(const QString & i);
3333
static QString stoqs(const string & s);
3434
static QString itoqs(const int & i);
3535

Marco.cpp

+31-37
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33

44
Marco::Marco(QWidget *parent)
55
{
6-
/* Faire un constructeur vide pour le viewer */
76

87
QHBoxLayout *layout_main = new QHBoxLayout;
98
QVBoxLayout *layout_infos = new QVBoxLayout;
10-
QHBoxLayout *layout_radio = new QHBoxLayout;
9+
1110
QList<QString> header ;
1211

1312
sum_manga = new QSummaryManga;
1413
sum_show = new QSummaryShow;
1514

16-
button_circular = new QRadioButton("Circular");
17-
button_normal = new QRadioButton("Normal");
18-
19-
header << "Name" << "Next" << "Status";
15+
header << "Name" << "Last" << "Next";
2016

21-
button_normal->setChecked(true);
2217
table_infos_scans = new QTableWidget(0,3);
2318
table_infos_shows = new QTableWidget(0,3);
2419

@@ -61,12 +56,9 @@ Marco::Marco(QWidget *parent)
6156

6257
fill_table(infos_vu);
6358

64-
layout_radio->addWidget(button_normal);
65-
layout_radio->addWidget(button_circular);
66-
layout_radio->addStretch(1);
6759
layout_infos->addWidget(table_infos_shows,1);
6860
layout_infos->addWidget(table_infos_scans,1);
69-
layout_infos->addItem(layout_radio);
61+
7062
layout_infos->addWidget(sum_manga);
7163

7264
layout_main->addLayout(layout_infos);
@@ -86,6 +78,7 @@ void Marco::fill_table(map<string,string> infos)
8678
{
8779
name = i->first;
8880
info = i->second;
81+
8982
if(info[0] == 'S')
9083
{
9184
table_infos_shows->insertRow(c_show);
@@ -97,48 +90,47 @@ void Marco::fill_table(map<string,string> infos)
9790
{
9891
table_infos_scans->insertRow(c_scan);
9992
table_infos_scans->setItem(c_scan,0,new QTableWidgetItem(Easylast::stoqs(name)));
100-
table_infos_scans->setItem(c_scan,1,new QTableWidgetItem(Easylast::itoqs(atoi(info.c_str())+1)));
10193

102-
if(Easylast::stoi(info)+1 <= Easylast::stoi(infos_dl[name]))
103-
table_infos_scans->setItem(c_scan,2,new QTableWidgetItem("Ready"));
104-
else
105-
table_infos_scans->setItem(c_scan,2,new QTableWidgetItem("Not Ready"));
94+
set_row_scan(c_scan,name,Easylast::stoi(info));
10695
c_scan++;
10796
}
108-
}
109-
97+
}
98+
}
99+
100+
void Marco::set_row_scan(int row,string name_scan,int num_scan)
101+
{
102+
table_infos_scans->setItem(row,1,new QTableWidgetItem(Easylast::itoqs(num_scan)));
103+
104+
if(num_scan+1 <= Easylast::stoi(infos_dl[name_scan]))
105+
table_infos_scans->setItem(row,2,new QTableWidgetItem(Easylast::itoqs(num_scan+1)+" Ready"));
106+
else
107+
table_infos_scans->setItem(row,2,new QTableWidgetItem(Easylast::itoqs(num_scan+1)+" Not Ready"));
110108
}
111109

112110
void Marco::set_new_scan(string scan_cur,int num_cur)
113111
{
114112
string cmd = "client_last --VU --inc -t "+scan_cur;
115113
int row_count = table_infos_scans->rowCount();
116-
system(cmd.c_str());
117-
114+
118115
sum_manga->setName(scan_cur);
119116
sum_manga->setChap(num_cur);
120117

121118
summary = sum_manga;
122119

123-
if(button_normal->isChecked())
120+
if(num_cur > Easylast::stoi(infos_vu[scan_cur]))
124121
{
125-
if(num_cur < Easylast::stoi(infos_dl[scan_cur]))
126-
viewer->setScan(scan_cur,num_cur+1);
127-
else
128-
{
129-
int curr_row = table_infos_scans->currentRow();
130-
if(curr_row < row_count)
131-
{
132-
string new_name = table_infos_scans->item(curr_row+1,0)->text().toStdString();
133-
int new_num = Easylast::stoi(table_infos_scans->item(curr_row+1,1)->text().toStdString());
134-
table_infos_scans->setCurrentCell(curr_row+1,0);
135-
viewer->setScan(new_name,new_num);
136-
}
137-
}
122+
for(int i = 0;i<table_infos_scans->rowCount();i++)
123+
124+
if(table_infos_scans->item(i,0)->text().toStdString() == scan_cur)
125+
set_row_scan(i,scan_cur,num_cur);
126+
127+
system(cmd.c_str());
138128
}
139-
140-
if(button_circular->isChecked())
141-
{
129+
130+
if(num_cur < Easylast::stoi(infos_dl[scan_cur]))
131+
viewer->setScan(scan_cur,num_cur+1);
132+
else
133+
{
142134
int curr_row = table_infos_scans->currentRow();
143135
if(curr_row < row_count)
144136
{
@@ -148,6 +140,8 @@ void Marco::set_new_scan(string scan_cur,int num_cur)
148140
viewer->setScan(new_name,new_num);
149141
}
150142
}
143+
144+
151145

152146

153147
}

Marco.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <QList>
1212
#include <QHeaderView>
1313
#include <QAbstractItemView>
14-
#include <QRadioButton>
1514
#include <map>
1615
#include "QSummary.h"
1716
#include "QSummaryManga.h"
@@ -31,7 +30,6 @@ Q_OBJECT
3130
public:
3231
Marco(QWidget *parent = 0);
3332

34-
3533
protected slots:
3634

3735
void set_new_scan(string scan_cur,int num_cur);
@@ -44,8 +42,6 @@ void double_clicked_scans(int row,int column);
4442
map<string,string> infos_vu;
4543
map<string,string> infos_dl;
4644

47-
QRadioButton *button_circular;
48-
QRadioButton *button_normal;
4945
QTableWidget *table_infos_scans;
5046
QTableWidget *table_infos_shows;
5147
Qtviewer *viewer;
@@ -54,6 +50,7 @@ QSummaryManga *sum_manga;
5450
QSummaryShow *sum_show;
5551

5652
void fill_table(map<string,string> infos);
53+
void set_row_scan(int row,string name_scan,int num_scan);
5754
};
5855

5956
#endif

QSummaryManga.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ QVBoxLayout* QSummaryManga::createLayoutScan()
7777
void QSummaryManga::find_summary()
7878
{
7979
string summ = Easylast::find_summary(lscan->text().toStdString(),atoi(lchap->text().toStdString().c_str()));
80-
80+
cout << summ <<endl;
8181
lsummary->setText(Easylast::stoqs(summ));
8282

8383
}
@@ -93,10 +93,12 @@ void QSummaryManga::add_summary()
9393
{
9494
if( isNumber(textChap))
9595
{
96+
cout << textSumm<<endl;
9697
if(Easylast::find_summary(textScan,atoi(textChap.c_str())) == "" )
9798
cmd = "client_last --as -t \""+textScan+"\" -n "+textChap+" -s \""+textSumm+"\"";
9899
else
99100
cmd = "client_last --us -t \""+textScan+"\" -n "+textChap+" -s \""+textSumm+"\"";
101+
100102

101103
if(system(cmd.c_str()) == 0)
102104
{

0 commit comments

Comments
 (0)