[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdesdk/lokalize/src
From: Nick Shaforostoff <shafff () ukr ! net>
Date: 2011-12-31 15:59:40
Message-ID: 20111231155940.255A6AC7DB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1270984 by shaforo:
*use combobox for choosing query syntax in tm search to save screen spase
*small changes in filesearch tab
M +32 -16 filesearch/filesearchtab.cpp
M +2 -2 filesearch/filesearchtab.h
M +1 -1 tm/qamodel.cpp
M +18 -42 tm/queryoptions.ui
M +38 -30 tm/tmtab.cpp
--- trunk/KDE/kdesdk/lokalize/src/filesearch/filesearchtab.cpp #1270983:1270984
@@ -144,7 +144,7 @@
public:
explicit SearchJob(const QStringList& f,
const SearchParams& sp,
- QTime startTime,
+ int sn,
QObject* parent=0);
~SearchJob(){}
@@ -153,18 +153,19 @@
public:
QStringList files;
SearchParams searchParams;
- QTime startTime;
+ int searchNumber;
- QMap<QString, QVector<FileSearchResult> > results; //filepath -> results
+ //QMap<QString, QVector<FileSearchResult> > results; //filepath -> results
+ SearchResults results; //plain
int m_size;
};
-SearchJob::SearchJob(const QStringList& f, const SearchParams& sp, QTime st, \
QObject* parent) +SearchJob::SearchJob(const QStringList& f, const SearchParams& sp, \
int sn, QObject* parent) : ThreadWeaver::Job(parent)
, files(f)
, searchParams(sp)
- , startTime(st)
+ , searchNumber(sn)
{
}
@@ -177,7 +178,7 @@
if (KDE_ISUNLIKELY(catalog.loadFromUrl(KUrl::fromPath(path), KUrl(), \
&m_size)!=0)) continue;
- QVector<FileSearchResult> catalogResults;
+ //QVector<FileSearchResult> catalogResults;
int numberOfEntries=catalog.numberOfEntries();
DocPosition pos(0);
for (;pos.entry<numberOfEntries;pos.entry++)
@@ -201,7 +202,9 @@
if (sp!=-1 && tp!=-1)
{
//TODO handle multiple results in same column
- FileSearchResult r;
+ //FileSearchResult r;
+ SearchResult r;
+ r.filepath=path;
r.docPos=pos;
if (!searchParams.sourcePattern.isEmpty())
\
r.sourcePositions<<StartLen(searchParams.sourcePattern.pos(), \
searchParams.sourcePattern.matchedLength()); @@ -213,12 +216,13 @@
r.isApproved=catalog.isApproved(pos);
//r.activePhase=catalog.activePhase();
- catalogResults<<r;
+ //catalogResults<<r;
+ results<<r;
}
}
}
- if (catalogResults.size())
- results[path]=catalogResults;
+ //if (catalogResults.size())
+ // results[path]=catalogResults;
}
qDebug()<<"done in"<<a.elapsed();
}
@@ -323,6 +327,7 @@
: LokalizeSubwindowBase2(parent)
// , m_proxyModel(new TMResultsSortFilterProxyModel(this))
, m_model(new FileSearchModel(this))
+ , m_lastSearchNumber(0)
, m_dbusId(-1)
{
setWindowTitle(i18nc("@title:window","Search and replace in files"));
@@ -394,6 +399,12 @@
// connect(m_proxyModel,SIGNAL(layoutChanged()),this,SLOT(displayTotalResultCount()));
+//BEGIN resizeColumnToContents
+ static const int \
maxInitialWidths[]={QApplication::desktop()->availableGeometry().width()/3,QApplication::desktop()->availableGeometry().width()/3};
+ int column=sizeof(maxInitialWidths)/sizeof(int);
+ while (--column>=0)
+ view->setColumnWidth(column, maxInitialWidths[column]);
+//END resizeColumnToContents
int i=6;
while (--i>ID_STATUS_PROGRESS)
@@ -437,7 +448,7 @@
statusBarItems.insert(1,QString());
m_searchFileListView->scrollTo();
- m_lastSearchStartTime=QTime::currentTime();
+ m_lastSearchNumber++;
SearchParams sp;
sp.sourcePattern.setPattern(ui_fileSearchOptions->querySource->text());
@@ -468,7 +479,7 @@
for(int j=i; j<lim;j++)
batch.append(files.at(j));
- SearchJob* job=new SearchJob(batch, sp, m_lastSearchStartTime);
+ SearchJob* job=new SearchJob(batch, sp, m_lastSearchNumber);
QObject::connect(job,SIGNAL(done(ThreadWeaver::Job*)),job,SLOT(deleteLater()));
QObject::connect(job,SIGNAL(done(ThreadWeaver::Job*)),this,SLOT(searchJobDone(ThreadWeaver::Job*)));
ThreadWeaver::Weaver::instance()->enqueue(job);
@@ -511,7 +522,7 @@
docPos.offset=sr.targetPositions.first().start;
selection =sr.targetPositions.first().len;
}
- qDebug()<<"fileOpenRequest"<<docPos.offset<<selection;
+ kDebug()<<"fileOpenRequest"<<docPos.offset<<selection;
emit fileOpenRequested(sr.filepath, docPos, selection);
}
@@ -594,9 +605,10 @@
void FileSearchTab::searchJobDone(ThreadWeaver::Job* job)
{
SearchJob* j=static_cast<SearchJob*>(job);
- if (j->startTime!=m_lastSearchStartTime)
+ if (j->searchNumber!=m_lastSearchNumber)
return;
+/*
SearchResults searchResults;
FileSearchResults::const_iterator i = j->results.constBegin();
@@ -612,10 +624,14 @@
}
m_model->appendSearchResults(searchResults);
+*/
+ m_model->appendSearchResults(j->results);
statusBarItems.insert(1,i18nc("@info:status message entries","Total: %1", \
m_model->rowCount()));
- if (searchResults.size())
- m_searchFileListView->scrollTo(searchResults.last().filepath);
+ if (j->results.size())
+ m_searchFileListView->scrollTo(j->results.last().filepath);
+
+ //ui_fileSearchOptions->treeView->setFocus();
}
//END FileSearchTab
--- trunk/KDE/kdesdk/lokalize/src/filesearch/filesearchtab.h #1270983:1270984
@@ -98,7 +98,7 @@
QVector<ThreadWeaver::Job*> m_runningJobs;
//to avoid results from previous search showing up in the new one
- QTime m_lastSearchStartTime;
+ int m_lastSearchNumber;
//QString m_dbusObjectPath;
int m_dbusId;
@@ -156,7 +156,7 @@
//Context,
Filepath,
TranslationStatus,
- Notes,
+ //Notes,
ColumnCount
};
--- trunk/KDE/kdesdk/lokalize/src/tm/qamodel.cpp #1270983:1270984
@@ -166,7 +166,7 @@
void QaModel::removeRow(const QModelIndex& rowIndex)
{
- //TODO optimize for contiguous selectimoons
+ //TODO optimize for contiguous selections
beginRemoveRows(QModelIndex(),rowIndex.row(),rowIndex.row());
QDomElement category=m_doc.elementsByTagName("qa").at(0).toElement().elementsByTagName("category").at(0).toElement();
--- trunk/KDE/kdesdk/lokalize/src/tm/queryoptions.ui #1270983:1270984
@@ -125,10 +125,8 @@
</widget>
</item>
<item>
- <layout class="QVBoxLayout" name="optionsLayout">
- <item>
- <layout class="QHBoxLayout" name="filemaskLayout">
- <item>
+ <layout class="QGridLayout" name="optionsLayout">
+ <item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string/>
@@ -141,7 +139,7 @@
</property>
</widget>
</item>
- <item>
+ <item row="1" column="2">
<widget class="KLineEdit" name="filemask">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -154,50 +152,25 @@
</property>
</widget>
</item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="queryStyleLayout">
- <item>
- <widget class="QRadioButton" name="substr">
- <property name="toolTip">
- <string>Case insensitive</string>
- </property>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_s">
<property name="text">
- <string comment="@option:radio">Substring</string>
+ <string>Query syntax:</string>
</property>
- <property name="checked">
- <bool>true</bool>
+ <property name="buddy">
+ <cstring>queryStyle</cstring>
</property>
</widget>
</item>
- <item>
- <widget class="QRadioButton" name="like">
- <property name="toolTip">
- <string>Space is AND operator. Case insensitive.</string>
+ <item row="2" column="2">
+ <widget class="KComboBox" name="queryStyle">
+ <property name="currentIndex">
+ <number>-1</number>
</property>
- <property name="text">
- <string comment="@option:radio">Google-like</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
</widget>
</item>
- <item>
- <widget class="QRadioButton" name="glob">
- <property name="toolTip">
- <string>Shell globs (* and ?). Case sensitive.</string>
- </property>
- <property name="text">
- <string comment="@option:radio">Wildcard</string>
- </property>
- </widget>
- </item>
</layout>
</item>
- </layout>
- </item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
@@ -251,6 +224,11 @@
</widget>
<customwidgets>
<customwidget>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
+ </customwidget>
+ <customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
@@ -263,9 +241,7 @@
<tabstop>invertSource</tabstop>
<tabstop>invertTarget</tabstop>
<tabstop>filemask</tabstop>
- <tabstop>substr</tabstop>
- <tabstop>like</tabstop>
- <tabstop>glob</tabstop>
+ <tabstop>queryStyle</tabstop>
<tabstop>doUpdateTM</tabstop>
<tabstop>treeView</tabstop>
</tabstops>
--- trunk/KDE/kdesdk/lokalize/src/tm/tmtab.cpp #1270983:1270984
@@ -52,6 +52,7 @@
#include <kxmlguifactory.h>
#include <threadweaver/ThreadWeaver.h>
#include <fastsizehintitemdelegate.h>
+#include <QStringListModel>
using namespace TM;
@@ -357,6 +358,31 @@
}
//END TMResultsSortFilterProxyModel
+class QueryStylesModel: public QStringListModel
+{
+public:
+ explicit QueryStylesModel(QObject* parent = 0);
+ QVariant data(const QModelIndex& item, int role) const;
+};
+
+QueryStylesModel::QueryStylesModel(QObject* parent): QStringListModel(parent)
+{
+ setStringList(QStringList(i18n("Substring"))<<i18n("Google-like")<<i18n("Wildcard"));
+}
+
+QVariant QueryStylesModel::data(const QModelIndex& item, int role) const
+{
+ if (role==Qt::ToolTipRole)
+ {
+ static QString tooltips[]={i18n("Case insensitive"),
+ i18n("Space is AND operator. Case insensitive."),
+ i18n("Shell globs (* and ?). Case sensitive.")};
+ return tooltips[item.row()];
+ }
+ return QStringListModel::data(item, role);
+}
+
+
//BEGIN TMWindow
TMTab::TMTab(QWidget *parent)
: LokalizeSubwindowBase2(parent)
@@ -442,11 +468,8 @@
connect(m_model,SIGNAL(resultsFetched()),this,SLOT(handleResults()));
connect(m_model,SIGNAL(finalResultCountFetched(int)),this,SLOT(displayTotalResultCount()));
- QButtonGroup* btnGrp=new QButtonGroup(this);
- btnGrp->addButton(ui_queryOptions->substr,(int)TMDBModel::SubStr);
- btnGrp->addButton(ui_queryOptions->like,(int)TMDBModel::WordOrder);
- btnGrp->addButton(ui_queryOptions->glob,(int)TMDBModel::Glob);
- connect(btnGrp,SIGNAL(buttonClicked(int)),m_model,SLOT(setQueryType(int)));
+ ui_queryOptions->queryStyle->setModel(new QueryStylesModel(this));
+ connect(ui_queryOptions->queryStyle,SIGNAL(currentIndexChanged(int)),m_model,SLOT(setQueryType(int)));
ui_queryOptions->dbName->setModel(DBFilesModel::instance());
ui_queryOptions->dbName->setRootModelIndex(DBFilesModel::instance()->rootIndex());
@@ -459,7 +482,14 @@
connect(ui_queryOptions->dbName, SIGNAL(activated(QString)), m_model, \
SLOT(setDB(QString)));
//connect(ui_queryOptions->dbName, SIGNAL(activated(QString)), this, \
SLOT(performQuery()));
+//BEGIN resizeColumnToContents
+ static const int \
maxInitialWidths[4]={QApplication::desktop()->availableGeometry().width()/3,QApplication::desktop()->availableGeometry().width()/3, \
50, 200}; + int column=sizeof(maxInitialWidths)/sizeof(int);
+ while (--column>=0)
+ view->setColumnWidth(column, maxInitialWidths[column]);
+//END resizeColumnToContents
+
int i=6;
while (--i>ID_STATUS_PROGRESS)
statusBarItems.insert(i,QString());
@@ -556,30 +586,8 @@
kDebug()<<"=DocPosition::UndefPart";
m_partToAlsoTryLater=DocPosition::UndefPart;
-//BEGIN resizeColumnToContents
- QTreeView* view=ui_queryOptions->treeView;
- static const int \
maxInitialWidths[4]={QApplication::desktop()->availableGeometry().width()/3,QApplication::desktop()->availableGeometry().width()/3, \
50, 200};
- int column=sizeof(maxInitialWidths)/sizeof(int);
- while (--column>=0)
- {
- //view->resizeColumnToContents(i);
- /*
- int max=0;
- int count=qMin(rowCount, 32);
- for (int row=0;row<count;++row)
- {
- int w = \
view->itemDelegate()->sizeHint(QStyleOptionViewItemV2(),m_model->index(row,column)).width();
- if (w>max)
- max=w;
+ ui_queryOptions->treeView->setFocus();
}
- if (count) //qWarning()<<(sum/count);
- view->setColumnWidth(column, qMin(max, maxInitialWidths[column]));
- */
- view->setColumnWidth(column, maxInitialWidths[column]);
- }
- view->setFocus();
-//END resizeColumnToContents
-}
void TMTab::displayTotalResultCount()
{
@@ -735,7 +743,7 @@
ui_queryOptions->queryTarget->setText(target);
ui_queryOptions->invertSource->setChecked(false);
ui_queryOptions->invertTarget->setChecked(false);
- ui_queryOptions->substr->click();
+ ui_queryOptions->queryStyle->setCurrentIndex(TMDBModel::SubStr);
performQuery();
}
@@ -762,7 +770,7 @@
ui_queryOptions->invertTarget->setChecked(false);
if (!package.isEmpty()) package='*'+package+'*';
ui_queryOptions->filemask->setText(package);
- ui_queryOptions->glob->click();
+ ui_queryOptions->queryStyle->setCurrentIndex(TMDBModel::Glob);
performQuery();
return true;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic