Skip to content

Commit

Permalink
1. 增加host过滤功能
Browse files Browse the repository at this point in the history
2. 修复条目背景色问题
  • Loading branch information
iptton committed Feb 20, 2014
1 parent c9f2fb5 commit 5aeb4cf
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 46 deletions.
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int main(int argc, char *argv[])
server->connect(server,SIGNAL(pipeComplete(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr)));
server->connect(server,SIGNAL(pipeError(RyPipeData_ptr)),&w,SLOT(onPipeUpdate(RyPipeData_ptr)));
bool isListenSuccess = server->listen(QHostAddress::Any,8889);

if(!isListenSuccess){
exit(1);
}
Expand Down
6 changes: 6 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,13 @@ MainWindow::MainWindow(QWidget *parent) :
statusBarStr = statusBarStr.append(address.toString()+" ");
}
statusBarStr = statusBarStr.append(tr(" --By AlloyTeam::iptton"));
statusBarStr = statusBarStr.append(tr(" version:")).append(CURRENT_VERSION);
ui->statusBar->showMessage(statusBarStr);
connect(ui->edit_filter,SIGNAL(textChanged(QString)),this,SLOT(onFilterTextChanged(QString)));
}

void MainWindow::onFilterTextChanged(QString filterText){
sortFilterProxyModel->setFilterText(filterText);
}

MainWindow::~MainWindow()
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private slots:
void on_actionDebug_triggered();
void on_actionCheckNew_triggered();
void loadConfigPage();
void onFilterTextChanged(QString);
};

#endif // MAINWINDOW_H
50 changes: 44 additions & 6 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<height>625</height>
<width>810</width>
<height>559</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Rythem</string>
</property>
Expand All @@ -19,13 +25,45 @@ background:#dddfe2;
}</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="RyConnectionTableView" name="tableView"/>
<widget class="QWidget" name="verticalLayoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="RyConnectionTableView" name="tableView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_filter">
<property name="placeholderText">
<string>[host filter]: qq.com|alloyteam</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="RyTabWidget" name="toolTabs">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
Expand Down Expand Up @@ -101,8 +139,8 @@ background:#dddfe2;
<rect>
<x>0</x>
<y>0</y>
<width>523</width>
<height>164</height>
<width>516</width>
<height>131</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -165,7 +203,7 @@ background:#dddfe2;
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<width>810</width>
<height>22</height>
</rect>
</property>
Expand Down
6 changes: 4 additions & 2 deletions rytablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ QVariant RyTableModel::data(const QModelIndex &index, int role) const{

RyPipeData_ptr d = pipesVector.at(index.row());
if(d->isMatchingRule){
return QVariant((int)Qt::cyan);
return Qt::cyan;
//return QVariant((int)Qt::cyan);
}else if(d->responseStatus.startsWith('4') || d->responseStatus.startsWith('5')){
return QVariant((int)Qt::darkCyan);
return Qt::darkGray;
//return QVariant((int)Qt::darkCyan);
}
}else{
return QVariant();
Expand Down
19 changes: 19 additions & 0 deletions rytablesortfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ bool RyTableSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIn
qDebug()<<"filterAcceptsRow got null";
return true;
}

//先处理文本过滤
if(!_filterText.isEmpty()){
QStringList hostFilterList = _filterText.split("|");
bool matchHost = false;
foreach(QString hostFilter,hostFilterList){
if(p->host.indexOf(hostFilter) != -1){
matchHost = true;
}
}
if(!matchHost){
return matchHost;
}
}
//qDebug()<<"filterAcceptsRow comparing"<<p->responseStatus;
if(_filterFlags & NoImageFilter){
if(p->getResponseHeader("Content-Type").toLower().indexOf("image")!=-1){
Expand Down Expand Up @@ -63,6 +77,11 @@ RyPipeData_ptr RyTableSortFilterProxyModel::getItem(const QModelIndex& proxyInde
return getItem(mapToSource(proxyIndex).row());
}

void RyTableSortFilterProxyModel::setFilterText(QString filterText){
_filterText = filterText;
invalidateFilter();
}

void RyTableSortFilterProxyModel::setFilter(int flag){
int oldFlags = _filterFlags;
_filterFlags = flag;
Expand Down
2 changes: 2 additions & 0 deletions rytablesortfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RyTableSortFilterProxyModel : public QSortFilterProxyModel
RyPipeData_ptr getItem(int sourceRow);
RyPipeData_ptr getItem(const QModelIndex& proxyIndex);

void setFilterText(QString filterText);
void setFilter(int filter);
int filter()const;
void setCustomeFilter(FilterCallBack);
Expand All @@ -43,6 +44,7 @@ public slots:

private:
RyTableModel *_sourceModel;
QString _filterText;
int _filterFlags;
FilterCallBack _filterCallback;

Expand Down
82 changes: 46 additions & 36 deletions rythem_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,101 +48,106 @@ Host: www.alloyteam.com
<context>
<name>MainWindow</name>
<message>
<location filename="mainwindow.ui" line="14"/>
<location filename="mainwindow.ui" line="20"/>
<source>Rythem</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="47"/>
<location filename="mainwindow.ui" line="61"/>
<source>[host filter]: qq.com|alloyteam</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="85"/>
<source>Inspector</source>
<translation>查看器</translation>
</message>
<message>
<location filename="mainwindow.ui" line="61"/>
<location filename="mainwindow.ui" line="81"/>
<location filename="mainwindow.ui" line="99"/>
<location filename="mainwindow.ui" line="119"/>
<source>TextView</source>
<translation>文本</translation>
</message>
<message>
<location filename="mainwindow.ui" line="71"/>
<location filename="mainwindow.ui" line="109"/>
<source>FormView</source>
<translation>表单</translation>
</message>
<message>
<location filename="mainwindow.ui" line="91"/>
<location filename="mainwindow.ui" line="129"/>
<source>ImageView</source>
<translation>图片</translation>
</message>
<message>
<location filename="mainwindow.ui" line="124"/>
<location filename="mainwindow.ui" line="162"/>
<source>HexView</source>
<translation>十六进制</translation>
</message>
<message>
<location filename="mainwindow.ui" line="134"/>
<location filename="mainwindow.ui" line="172"/>
<source>Rules</source>
<translation>替换规则</translation>
</message>
<message>
<location filename="mainwindow.ui" line="141"/>
<location filename="mainwindow.ui" line="179"/>
<source>about:blank</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="150"/>
<location filename="mainwindow.ui" line="188"/>
<source>Composer</source>
<translation>发送器</translation>
</message>
<message>
<location filename="mainwindow.ui" line="203"/>
<location filename="mainwindow.ui" line="206"/>
<location filename="mainwindow.ui" line="241"/>
<location filename="mainwindow.ui" line="244"/>
<source>Clear All</source>
<translation>清除</translation>
</message>
<message>
<location filename="mainwindow.ui" line="222"/>
<location filename="mainwindow.ui" line="225"/>
<location filename="mainwindow.ui" line="260"/>
<location filename="mainwindow.ui" line="263"/>
<source>Begein Capture</source>
<translation>开始抓包</translation>
</message>
<message>
<location filename="mainwindow.ui" line="237"/>
<location filename="mainwindow.ui" line="240"/>
<location filename="mainwindow.ui" line="275"/>
<location filename="mainwindow.ui" line="278"/>
<source>water fall</source>
<translation>瀑布图</translation>
</message>
<message>
<location filename="mainwindow.ui" line="252"/>
<location filename="mainwindow.ui" line="290"/>
<source>long cache</source>
<translation>长缓存</translation>
</message>
<message>
<location filename="mainwindow.ui" line="255"/>
<location filename="mainwindow.ui" line="293"/>
<source>set sessions matching rule with long cache</source>
<translation>符合替换规则的请求,返回内容设置长时间缓存</translation>
</message>
<message>
<location filename="mainwindow.ui" line="267"/>
<location filename="mainwindow.ui" line="305"/>
<source>Debug</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="270"/>
<location filename="mainwindow.ui" line="308"/>
<source>debug</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="282"/>
<location filename="mainwindow.ui" line="320"/>
<source>CheckNew</source>
<translation>检查更新</translation>
</message>
<message>
<location filename="mainwindow.ui" line="300"/>
<location filename="mainwindow.ui" line="338"/>
<source>liveLoad</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="303"/>
<location filename="mainwindow.ui" line="341"/>
<source>toggle live load</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -184,51 +189,56 @@ Host: www.alloyteam.com
<translation type="unfinished"> --AlloyTeam::iptton</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="542"/>
<location filename="mainwindow.cpp" line="521"/>
<source> version:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="548"/>
<source>&amp;File</source>
<translation type="unfinished">文件(&amp;F)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="543"/>
<location filename="mainwindow.cpp" line="549"/>
<source>&amp;import session...</source>
<translation type="unfinished">导入会话(&amp;i)...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="544"/>
<location filename="mainwindow.cpp" line="550"/>
<source>hide image requests</source>
<translation type="unfinished">隐藏图片请求</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="546"/>
<location filename="mainwindow.cpp" line="552"/>
<source>hide 304s</source>
<translation type="unfinished">隐藏304</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="548"/>
<location filename="mainwindow.cpp" line="554"/>
<source>show matching sessions only</source>
<translation type="unfinished">只显示匹配规则的请求</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="550"/>
<location filename="mainwindow.cpp" line="556"/>
<source>hide connect tunnels</source>
<translation type="unfinished">隐藏Connect遂道</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="558"/>
<location filename="mainwindow.cpp" line="564"/>
<source>select file to open</source>
<translation type="unfinished">选择文件</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="824"/>
<location filename="mainwindow.cpp" line="853"/>
<location filename="mainwindow.cpp" line="854"/>
<location filename="mainwindow.cpp" line="830"/>
<location filename="mainwindow.cpp" line="859"/>
<location filename="mainwindow.cpp" line="860"/>
<source>start capture</source>
<translation type="unfinished">开始抓包</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="833"/>
<location filename="mainwindow.cpp" line="849"/>
<location filename="mainwindow.cpp" line="850"/>
<location filename="mainwindow.cpp" line="839"/>
<location filename="mainwindow.cpp" line="855"/>
<location filename="mainwindow.cpp" line="856"/>
<source>stop capture</source>
<translation type="unfinished">停止抓包</translation>
</message>
Expand Down
4 changes: 2 additions & 2 deletions ryupdatechecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <QtNetwork>

#ifdef Q_OS_MAC
#define CURRENT_VERSION "0.13.11.15"
#define CURRENT_VERSION "1.0.140220"
#endif
#ifdef Q_OS_LINUX
#define CURRENT_VERSION "0.5.09.21"
#endif
#ifdef Q_OS_WIN
#define CURRENT_VERSION "0.13.11.15"
#define CURRENT_VERSION "1.0.140220"
#endif

#define RYTHEM_UPDATE_PREFIX "http://rythem.alloyteam.com/update.php?"
Expand Down

0 comments on commit 5aeb4cf

Please sign in to comment.