disable/enable buttons dep. on state

This commit is contained in:
dockes 2005-11-30 10:25:46 +00:00
parent 5f9675fd7b
commit 667cad5753
2 changed files with 60 additions and 11 deletions

View File

@ -76,7 +76,10 @@
</widget> </widget>
<widget class="QPushButton"> <widget class="QPushButton">
<property name="name"> <property name="name">
<cstring>Search</cstring> <cstring>searchPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Search</string> <string>Search</string>
@ -86,6 +89,9 @@
<property name="name"> <property name="name">
<cstring>clearqPB</cstring> <cstring>clearqPB</cstring>
</property> </property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Clear</string> <string>Clear</string>
</property> </property>
@ -95,7 +101,10 @@
</widget> </widget>
<widget class="QPushButton"> <widget class="QPushButton">
<property name="name"> <property name="name">
<cstring>listPrevPb</cstring> <cstring>listPrevPB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Previous page</string> <string>Previous page</string>
@ -105,6 +114,9 @@
<property name="name"> <property name="name">
<cstring>listNextPB</cstring> <cstring>listNextPB</cstring>
</property> </property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Next page</string> <string>Next page</string>
</property> </property>
@ -260,10 +272,10 @@
<slot>fileStart_IndexingAction_activated()</slot> <slot>fileStart_IndexingAction_activated()</slot>
</connection> </connection>
<connection> <connection>
<sender>Search</sender> <sender>searchPB</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>RecollMain</receiver> <receiver>RecollMain</receiver>
<slot>Search_clicked()</slot> <slot>queryText_returnPressed()</slot>
</connection> </connection>
<connection> <connection>
<sender>queryText</sender> <sender>queryText</sender>
@ -272,7 +284,7 @@
<slot>queryText_returnPressed()</slot> <slot>queryText_returnPressed()</slot>
</connection> </connection>
<connection> <connection>
<sender>listPrevPb</sender> <sender>listPrevPB</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>RecollMain</receiver> <receiver>RecollMain</receiver>
<slot>listPrevPB_clicked()</slot> <slot>listPrevPB_clicked()</slot>
@ -319,6 +331,18 @@
<receiver>RecollMain</receiver> <receiver>RecollMain</receiver>
<slot>showDocHistory()</slot> <slot>showDocHistory()</slot>
</connection> </connection>
<connection>
<sender>queryText</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>RecollMain</receiver>
<slot>searchTextChanged(const QString&amp;)</slot>
</connection>
<connection>
<sender>clearqPB</sender>
<signal>clicked()</signal>
<receiver>queryText</receiver>
<slot>clear()</slot>
</connection>
</connections> </connections>
<includes> <includes>
<include location="local" impldecl="in declaration">preview.h</include> <include location="local" impldecl="in declaration">preview.h</include>
@ -349,7 +373,7 @@
<slot>reslistTE_clicked( int par, int car )</slot> <slot>reslistTE_clicked( int par, int car )</slot>
<slot>reslistTE_delayedclick()</slot> <slot>reslistTE_delayedclick()</slot>
<slot>queryText_returnPressed()</slot> <slot>queryText_returnPressed()</slot>
<slot>Search_clicked()</slot> <slot>searchPB_clicked()</slot>
<slot>clearqPB_clicked()</slot> <slot>clearqPB_clicked()</slot>
<slot>listPrevPB_clicked()</slot> <slot>listPrevPB_clicked()</slot>
<slot>listNextPB_clicked()</slot> <slot>listNextPB_clicked()</slot>
@ -358,10 +382,11 @@
<slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot> <slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot>
<slot>showAboutDialog()</slot> <slot>showAboutDialog()</slot>
<slot>showDocHistory()</slot> <slot>showDocHistory()</slot>
<slot>searchTextChanged( const QString &amp; text )</slot>
</slots> </slots>
<functions> <functions>
<function access="private">init()</function> <function access="private">init()</function>
<function returnType="bool">close( bool alsoDelete )</function> <function returnType="bool">close( bool )</function>
<function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function> <function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
<function access="private">startPreview( int docnum )</function> <function access="private">startPreview( int docnum )</function>
</functions> </functions>

View File

@ -390,7 +390,7 @@ void RecollMain::queryText_returnPressed()
} }
void RecollMain::Search_clicked() void RecollMain::searchPB_clicked()
{ {
queryText_returnPressed(); queryText_returnPressed();
} }
@ -424,13 +424,18 @@ void RecollMain::listNextPB_clicked()
reslist_winfirst)); reslist_winfirst));
// If we are already on the last page, nothing to do: // If we are already on the last page, nothing to do:
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt)) if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt)) {
listNextPB->setEnabled(false);
return; return;
}
if (reslist_winfirst < 0) if (reslist_winfirst < 0) {
reslist_winfirst = 0; reslist_winfirst = 0;
else listPrevPB->setEnabled(false);
} else {
listPrevPB->setEnabled(true);
reslist_winfirst += respagesize; reslist_winfirst += respagesize;
}
bool gotone = false; bool gotone = false;
reslistTE->clear(); reslistTE->clear();
@ -534,6 +539,12 @@ void RecollMain::listNextPB_clicked()
if (reslist_winfirst < 0) if (reslist_winfirst < 0)
reslist_winfirst = -1; reslist_winfirst = -1;
} }
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize >= resCnt)) {
listNextPB->setEnabled(false);
} else {
listNextPB->setEnabled(true);
}
} }
// If a preview (toplevel) window gets closed by the user, we need to // If a preview (toplevel) window gets closed by the user, we need to
@ -666,3 +677,16 @@ void RecollMain::showDocHistory()
docsource = new DocSequenceHistory(rcldb, history); docsource = new DocSequenceHistory(rcldb, history);
listNextPB_clicked(); listNextPB_clicked();
} }
void RecollMain::searchTextChanged(const QString & text)
{
if (text.isEmpty()) {
searchPB->setEnabled(false);
clearqPB->setEnabled(false);
} else {
searchPB->setEnabled(true);
clearqPB->setEnabled(true);
}
}