42 #include "NCPkgPatchSearch.h" 45 #include "YMenuButton.h" 47 #include "NCLayoutBox.h" 48 #include "NCSpacing.h" 51 #include "NCPkgStrings.h" 52 #include "NCPackageSelector.h" 71 : NCPopup( at, false )
75 createLayout( _(
"Search for Patches" ) );
86 NCPkgPatchSearch::~NCPkgPatchSearch()
98 void NCPkgPatchSearch::createLayout(
const std::string & headline )
101 NCLayoutBox * vSplit =
new NCLayoutBox(
this, YD_VERT );
103 new NCSpacing( vSplit, YD_VERT,
false, 0.8 );
105 new NCLabel( vSplit, headline,
true,
false );
107 new NCSpacing( vSplit, YD_VERT,
false, 0.6 );
109 NCFrame * frame0 =
new NCFrame( vSplit,
"" );
112 searchExpr =
new NCComboBox( frame0,
113 NCPkgStrings::SearchPhrase(),
116 searchExpr->setStretchable( YD_HORIZ,
true );
118 searchExpr->addItem(
new YTableItem() );
120 new NCSpacing( vSplit, YD_VERT,
false, 0.6 );
122 NCMultiSelectionBox * settings =
new NCMultiSelectionBox( vSplit, NCPkgStrings::SearchIn() );
123 YItemCollection items;
124 searchName =
new YItem ( _(
"Name of the Patch" ),
true);
125 items.push_back( searchName );
126 searchSum =
new YItem ( _(
"Summary" ),
true);
127 items.push_back( searchSum );
128 settings->addItems( items );
130 new NCSpacing( vSplit, YD_VERT,
false, 0.6 );
131 NCLayoutBox * hSplit3 =
new NCLayoutBox( vSplit, YD_HORIZ );
132 new NCSpacing( hSplit3, YD_HORIZ,
true, 0.2 );
136 okButton->setFunctionKey( 10 );
138 new NCSpacing( hSplit3, YD_HORIZ,
true, 0.4 );
141 cancelButton->setFunctionKey( 9 );
143 new NCSpacing( hSplit3, YD_HORIZ,
true, 0.2 );
144 new NCSpacing( vSplit, YD_VERT,
false, 0.6 );
155 NCursesEvent & NCPkgPatchSearch::showSearchPopup()
157 postevent = NCursesEvent();
163 searchExpr->setKeyboardFocus();
165 }
while ( postAgain() );
176 std::string NCPkgPatchSearch::getSearchExpression()
const 185 value = searchExpr->text();
186 searchExpr->getListSize();
188 searchExpr->addItem( value,
true );
200 int NCPkgPatchSearch::preferredWidth()
202 return NCurses::cols()/2;
211 int NCPkgPatchSearch::preferredHeight()
224 NCursesEvent NCPkgPatchSearch::wHandleInput( wint_t ch )
227 return NCursesEvent::cancel;
230 if ( ch == KEY_RETURN )
231 return NCursesEvent::button;
233 return NCDialog::wHandleInput( ch );
244 bool NCPkgPatchSearch::postAgain()
246 if ( ! postevent.widget )
249 postevent.result =
"";
251 if ( postevent.widget == cancelButton )
253 postevent = NCursesEvent::cancel;
255 else if ( postevent == NCursesEvent::button )
258 postevent.result = getSearchExpression();
260 std::string filter = postevent.result;
261 bool checkName = searchName->selected();
262 bool checkSum = searchSum->selected();
267 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
bool fillPatchSearchList(const std::string &expr, bool checkName, bool checkSum)
Fills the package table with packages matching the search expression.
static const std::string CancelLabel()
The label of the Cancel button.
static const std::string OKLabel()
The label of the OK button.