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();
162 searchExpr->setKeyboardFocus();
164 }
while ( postAgain() );
175 std::string NCPkgPatchSearch::getSearchExpression()
const 184 value = searchExpr->text();
185 searchExpr->getListSize();
187 searchExpr->addItem( value,
true );
199 int NCPkgPatchSearch::preferredWidth()
201 return NCurses::cols()/2;
210 int NCPkgPatchSearch::preferredHeight()
223 NCursesEvent NCPkgPatchSearch::wHandleInput( wint_t ch )
226 return NCursesEvent::cancel;
229 if ( ch == KEY_RETURN )
230 return NCursesEvent::button;
232 return NCDialog::wHandleInput( ch );
243 bool NCPkgPatchSearch::postAgain()
245 if ( ! postevent.widget )
248 postevent.result =
"";
250 if ( postevent.widget == cancelButton )
252 postevent = NCursesEvent::cancel;
254 else if ( postevent == NCursesEvent::button )
257 postevent.result = getSearchExpression();
259 std::string filter = postevent.result;
260 bool checkName = searchName->selected();
261 bool checkSum = searchSum->selected();
262 packager->fillPatchSearchList( filter, checkName, checkSum );
266 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
static const std::string CancelLabel()
The label of the Cancel button.
static const std::string OKLabel()
The label of the OK button.